Aurigma Forums
»
Upload Suite
»
Discussions – ActiveX/Java Uploader
»
struts action don't receive files data from POST request
Rank: Newbie
Groups: Member
Joined: 5/26/2010(UTC) Posts: 3
|
We have a web site, that use struts. The Image Unloader is integrated in a page uploader.jsp. We define this control to call action 'uploadimage.action'. This action is called, but when is parse request the file items list size is 0. Code:listFileItems = fu.parseRequest(request);
System.out.println(listFileItems.size()); // 0
Why this list have zero size? The following is the code: //////////////////////////////////////////////// // uploader.jsp Code:<form metod="POST">
<script language="javascript" src="/JSPs/ImageUploader/Scripts/iuembed.js"> </script>
<script language="javascript">
var iu = new ImageUploaderWriter("ImageUploader", 650, 450);
// If you do not want to use ActiveX or Java version, set the appropriate
// property to false.
iu.activeXControlEnabled = false;
iu.javaAppletEnabled = true;
iu.javaAppletCodeBase="/JSPs/ImageUploader/";
// ... initialize params ...
iu.addParam("LicenseKey", "xxxxx-xxxxxx-xxxxxxx-xxxxxxxx-xxxxxxxx");
iu.addParam("Action", "/uploadimage.action");
iu.addParam("PaneLayout", "OnePane");
iu.addParam("UploadSourceFile", "true");
iu.addParam("ShowDebugWindow", "true");
iu.addParam("AllowRotate", "false");
iu.showNonemptyResponse = "off";
iu.addParam("UploadView", "AdvancedDetails");
iu.addParam("FilesPerOnePackageCount", "1");
iu.addParam("MaxConnectionCount", "1");
iu.writeHtml();
</script>
</form>
Code:////////////////////////////////////////////////
// UploadImage.java
public class UploadImage extends BaseAction {
/**
*
*/
private static final long serialVersionUID = 83964164931876309L;
public String execute(){
String galleryPath = "/Gallery/";
//Process upload.
ServletContext context = ServletActionContext.getServletContext();
String absGalleryPath = context.getRealPath(galleryPath);
String absThumbnailsPath = context.getRealPath(galleryPath + "/Thumbnails");
String absTempPath = context.getRealPath(galleryPath + "/Temp");
DiskFileUpload fu = new DiskFileUpload();
//Set maximum size before a FileUploadException will be thrown.
fu.setSizeMax(100000000);
//Set maximum size that will be stored in memory.
fu.setSizeThreshold(4096);
//Set the location for saving data that is larger than getSizeThreshold().
fu.setRepositoryPath(absTempPath);
//Get uploaded files.
List listFileItems = null;
try {
HttpServletRequest request = ServletActionContext.getRequest();
listFileItems = fu.parseRequest(request);
System.out.println(listFileItems.size()); // 0
} catch (FileUploadException e) {
return ERROR;
}
//Put them in hash table for fast access.
Hashtable fileItems = new Hashtable();
for (int i = 0; i < listFileItems.size(); i++) {
FileItem fileItem = (FileItem)(listFileItems.get(i));
fileItems.put(fileItem.getFieldName(), fileItem);
}
//Get total number of uploaded files (all files are uploaded in a single package).
int fileCount = Integer.parseInt(((FileItem) fileItems.get("FileCount")).getString());
........................................... Edited by user Wednesday, May 26, 2010 7:42:55 AM(UTC)
| Reason: Not specified
|
|
|
|
Rank: Advanced Member
Groups: Member
Joined: 3/9/2008(UTC) Posts: 554
Was thanked: 1 time(s) in 1 post(s)
|
Hi, I just tried to reproduce this problem locally, but everything worked well. It seems that you get incorrect or corrupted POST-request on your server. Let's try to debug this problem. In attachment you can find ExtractFiles.jsp file which allows to dump POST-request. Just put it on your server and point this script in Action property: Code:iu.addParam("Action", " ExtractFiles.jsp");
Try to reproduce your problem. After upload completed you will find ExtractDump.txt in the application root folder. Please send me this .txt file. |
|
|
|
|
Rank: Newbie
Groups: Member
Joined: 5/26/2010(UTC) Posts: 3
|
I executed this script on my server, but the result is empty file. in the following line the len is -1 :
while ((len = inStream.read(buf)) > 0) {
|
|
|
|
Rank: Advanced Member
Groups: Member
Joined: 3/9/2008(UTC) Posts: 554
Was thanked: 1 time(s) in 1 post(s)
|
Hi, Could you please submit a case about this problem. In support case post the direct link to the page where you experience problem with Image Uploader, also send me login information if necessary. |
|
|
|
|
Rank: Newbie
Groups: Member
Joined: 5/26/2010(UTC) Posts: 3
|
Hi Tamila With the action the POST request is really corrupted. I tried the same with servlet and it work.
Regards.
|
|
|
|
Rank: Advanced Member
Groups: Member
Joined: 3/9/2008(UTC) Posts: 554
Was thanked: 1 time(s) in 1 post(s)
|
Hmm...
Do you still experience the problem? It is not clear.
|
|
|
|
|
Aurigma Forums
»
Upload Suite
»
Discussions – ActiveX/Java Uploader
»
struts action don't receive files data from POST request
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.