Skip to content

Commit

Permalink
Merge pull request #22 from ylnb91/master
Browse files Browse the repository at this point in the history
合并到主分支
  • Loading branch information
tidezyc committed May 8, 2013
2 parents 1dff68c + 2f68a8e commit e1cfafb
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 1 deletion.
28 changes: 28 additions & 0 deletions WebRoot/WEB-INF/views/admin/upload.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<#include "/layout/admin/_layout.html" />
<@head title="首页|四眼井|互联网人的乐园 ">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<script src="/upload/jquery.uploadify.min.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="/upload/uploadify.css">
<style type="text/css">
body {
font: 13px Arial, Helvetica, Sans-serif;
}
</style>
</@head>
<@body>
<form>
<div id="queue"></div>
<input id="file_upload" name="file_upload" type="file" multiple="true">
</form>

</@body>
<@script>
<script type="text/javascript">
$(function() {
$('#file_upload').uploadify({
'swf' : '/upload/uploadify.swf',
'uploader' : 'upload/img'
})
});
</script>
</@script>
9 changes: 8 additions & 1 deletion src/me/thinkjet/controller/UploadController.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@
/**
* kindeditor 专用 文件&图片上传实现
*/
@ControllerBind(controllerKey = "/upload", viewPath = "")
@ControllerBind(controllerKey = "/upload", viewPath = "/")
public class UploadController extends Controller {

public void index(){
render("upload.html");
}

public void file() {
File file = this.getFile().getFile();
String url = UploadService.uplaodFileToLocal(file);
Expand All @@ -27,6 +32,7 @@ public void file() {
}

public void img() {
System.out.println("ok");
File file = this.getFile().getFile();
String url = UploadService.uplaodImgToLocal(file);
if (file.exists())
Expand All @@ -37,6 +43,7 @@ public void img() {
} else {
this.setAttr("error", 1);
}
System.out.println(url);
this.renderJson();
}

Expand Down
31 changes: 31 additions & 0 deletions src/me/thinkjet/controller/admin/UploadController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package me.thinkjet.controller.admin;

import java.io.File;

import me.thinkjet.service.upyun.UploadService;

import com.jfinal.core.Controller;
import com.jfinal.ext.route.ControllerBind;

@ControllerBind(controllerKey = "/admin/upload", viewPath = "admin/")
public class UploadController extends Controller {

public void index() {
render("upload.html");
}

public void img() {
File file = this.getFile().getFile();
String url = UploadService.uplaodImgToLocal(file);
if (file.exists())
file.delete();
if (url != null) {
this.setAttr("error", 0);
this.setAttr("url", url);
} else {
this.setAttr("error", 1);
}
this.renderJson();
}

}

0 comments on commit e1cfafb

Please sign in to comment.