Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to upload file by using uploadify
    text
    copied!<p>I'm using uploadify to upload file</p> <p>There is Jsp Code</p> <pre><code>&lt;%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%&gt; &lt;%@ include file="/common/tags.jsp"%&gt; &lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN"&gt; &lt;html&gt; &lt;head&gt; &lt;link href="${path }/css/uploadify.css" rel="stylesheet" /&gt; &lt;script type="text/javascript" src="${path }/js/jquery-1.7.2.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="${path }/js/swfobject.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="${path }/js/jquery.uploadify.min.js"&gt;&lt;/script&gt; &lt;script&gt; $("#uploadify").uploadify( { 'swf' : '${path }/js/uploadify.swf', 'uploader' : '${path }/js/uploadify.swf', 'script' : '${path }/sys/addImage', 'queueID' : 'fileQueue', 'queueSizeLimit' : 5, 'fileTypeDesc' : 'exts', 'fileTypeExts' : '*.bmp;*.jpg;*.jpeg;*.png', 'method' : 'post', 'fileSizeLimit' : 10000, 'auto' : false, 'multi' : true, 'uploadLimit' : 5, 'buttonText' : 'browse', 'onUploadError' : function (file, errorCode, errorMsg, errorString) { alert("errorCode:" + errorCode + "\n" + "errorMsg:" + errorMsg + "\n" + "errorString:" + errorString); }, 'onUploadSuccess' : function (file, data, response) { $('#sendDialog').dialog('close'); $('#listTable').datagrid('reload'); } }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="fileQueue"&gt;&lt;/div&gt; &lt;input type="file" name="fileupload" id="uploadify" /&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>and Struts Action code</p> <pre><code>@Namespace("/sys") @Controller public class ImageAction extends BaseAction { private File fileupload; private String fileuploadFileName; public File getFileupload() { return fileupload; } public void setFileupload(File fileupload) { this.fileupload = fileupload; } public String getFileuploadFileName() { return fileuploadFileName; } public void setFileuploadFileName(String fileuploadFileName) { this.fileuploadFileName = fileuploadFileName; } @Action(value = "addImage") public void addImage() { String newFileName = "", extName = ""; String savePath = request.getSession().getServletContext().getRealPath("/"); savePath = savePath + getImgFloder(); if (fileuploadFileName.lastIndexOf(".") &gt;= 0) { extName = fileuploadFileName.substring(fileuploadFileName.lastIndexOf(".")); } newFileName = savePath + UUID.randomUUID().toString() + extName; fileupload.renameTo(new File(newFileName)); } } </code></pre> <p>i set a breakpoint at top line of <code>addImage()</code></p> <p>when i select some files and execute <code>$("#uploadify").uploadify('upload','*');</code></p> <p>the event <code>onUploadSuccess</code> is trigger, but the breakpoint is not trigger</p> <p>how to solve it?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload