使用SWFUpload控件上传文件,服务器端我拿到文件流后写入文件。问题是:

为什么请求一发出去,就能把文件上传到服务器,其实我只想在服务器端拿到流拿到文件流后我自己写文件。如何不让SWFUpload在服务器端写文件呢?

3个回答

!!!!

要看你服务器端的代码了。。swfupload只是一个前端工具,只负责发送请求,不会操作服务器保存的。。。

我在服务器端拿到文件流以后,把文件写入到指定路径。成功了,然后发现旁边还有个文件夹,里面存了文件打开后发现也是我刚刚上传的文件。最后经过测试发现使用SWFUpload组件上传时只要已发送请求到服务器,竟管不调用我的写入文件逻辑。文件也会被写入到服务器的一个文件夹。不知
道是怎么回事。我用这个组件其实就想拿到文件流,逻辑我自己写。可是这个组件是怎么通过钱端把文件写入到服务器的呢?

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" session="false" %>


Title

<br> var contextPath=&quot;&lt;%=request.getContextPath()%&gt;&quot;;<br>


.progressbar { position:relative;background:#bbb;width:100%;height:16px;overflow:hidden; } .progressbar-percent { position:absolute;height:18px;background:blue;left:0;top:0px;overflow:hidden; z-index:1; } .progressbar-label { position:absolute;left:0;top:0;width:100%;font-size:13px;color:White; z-index:10; text-align:center; height:16px;line-height:16px; }

var swfu; window.onload = function () { swfu = new SWFUpload({ upload_url: contextPath+"/cn.gov.customs.cadp.components.cupaa.fm.upload.uploadFile.flow", post_params: {"test" : "test"}, // File Upload Settings file_size_limit : "70 MB", // 1000MB file_types : "*.*", file_types_description : "所有文件", file_upload_limit : "0", file_queue_error_handler : fileQueueError, file_dialog_complete_handler : fileDialogComplete,//选择好文件后提交 file_queued_handler : fileQueued, upload_progress_handler : uploadProgress, upload_error_handler : uploadError, upload_success_handler : uploadSuccess, upload_complete_handler : uploadComplete, // Button Settings button_placeholder_id : "spanButtonPlaceholder", button_width: 43, button_height: 18, button_text : '新增', //button_text_style : '.button { font-family: Helvetica, Arial, sans-serif; font-size: 12pt; } .buttonSmall { font-size: 10pt; }', button_text_top_padding: 0, button_text_left_padding: 18, button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT, button_cursor: SWFUpload.CURSOR.HAND, // Flash Settings flash_url : "js/swfupload.swf", custom_settings : { upload_target : "divFileProgressContainer" }, // Debug Settings debug: false //是否显示调试窗口 }); }; function startUploadFile(){ swfu.startUpload(); }

</div>
<div id="datagrid1" class="nui-datagrid" style="width:100%;height:100px;" 
  idField="id" allowResize="true" showPager="false" multiSelect="true"
sizeList="[20,30,50,100]" pageSize="20" allowSortColumn="false" >
<div property="columns">
    <div type="indexcolumn" ></div>
    <div type="checkcolumn"></div>
    <div field="id" width="120" headerAlign="center" allowSort="true">ID</div>
    <div field="name" width="120" headerAlign="center" allowSort="true">文件名</div>    
    <div field="status" width="120" headerAlign="center" allowSort="true">状态</div>                            
    <div field="message" width="100" align="center" headerAlign="center">队列</div>
    <div field="jd" width="214" align="center" headerAlign="center">进度</div>
</div>
</div>
<script type="text/javascript" src="js/any_upload.js"></script>


立即提问