读书人

jsp为啥收不到FLASH上传的文件

发布时间: 2011-11-08 23:00:52 作者: rapoo

jsp为什么收不到FLASH上传的文件
用FLASH的FileReference类进行文件选择连到jsp进行上传保存,但是文件老不能保存,flash也不报什么错。
jsp用了jspsmart上传,从HTML传过来的FILE可以保存,但用flash就不能保存了,请各位高手指点一下啊。

JSP代码
<%@ page import= "com.jspsmart.upload.* "%>
<%@ page import= "java.io.* " %>
<jsp:useBean id= "mySmartUpload " scope= "page " class= "com.jspsmart.upload.SmartUpload " />
<%
java.lang.String strFolderName,serverPath,strFolderPath;
java.io.File objFolder;
int intLength,num;
String ext= "gif,jpg,jpeg,bmp,png,JPG,GIF,BMP,PNG ";
String paths= "/upload/ ";
int max_size=500000;
mySmartUpload.setDenyPhysicalPath(true);
int count=0;
mySmartUpload.initialize(pageContext);
mySmartUpload.setAllowedFilesList(ext);
mySmartUpload.setMaxFileSize(max_size);
mySmartUpload.upload();
com.jspsmart.upload.File myFile = mySmartUpload.getFiles().getFile(0);
myFile.saveAs(paths + myFile.getFileName(), mySmartUpload.SAVE_VIRTUAL);
%>


FLASH代码
Stage.showMenu = false;

import flash.net.FileReference;

var fileRef:FileReference = new FileReference();

var fileLsn:Object = new Object();

var fileTyp:Array = new Array({description: "Image files ", extension: "*.jpg;*.gif "}, {description: "Document files ", extension: "*.txt;*.doc "});
btnBrowse.onRelease = function()
{
fileRef.browse(fileTyp);
};
btnUpload.onRelease = function()
{

fileRef.upload( "http://localhost:8080/up/upload.jsp "); //传到的jsp页面,也就是上面的jsp代码
};
btnClear.onRelease = function()
{
strState.text = " ";
};

fileLsn.onSelect = function(file:FileReference)
{
strState.text += "onSelect ' "+file.name+ " '\n ";
};

fileLsn.onCancel = function(file:FileReference)
{
strState.text += "Cancel!\n ";
};

fileLsn.onOpen = function(file:FileReference)
{
strState.text += "Uploading... ' "+file.name+ " '\n ";
};

fileLsn.onComplete = function(file:FileReference)
{
strState.text += "File ' "+file.name+ " ' upload successfull!\n ";
};

fileLsn.onProgress = function(file:FileReference, bytesLoaded:Number, bytesTotal:Number):Void
{
strState.text += "onProgress: "+file.name+ " with bytesLoaded: "+bytesLoaded+ " bytesTotal: "+bytesTotal+ "\n ";
};

fileLsn.onHTTPError = function(file:FileReference, httpError:Number)


{
strState.text += "HTTP ERROR: "+httpError+ "\n ";
};

fileLsn.onIOError = function(file:FileReference):Void
{
strState.text += "IO Error: "+file.name+ "\n ";
};

fileLsn.onSecurityError = function(file:FileReference, errorString:String):Void
{
strState.text += "onSecurityError: "+file.name+ " errorString: "+errorString;
};

fileRef.addListener(fileLsn);


[解决办法]
关注中

读书人网 >Java Web开发

热点推荐