ASP.Net:写作file..HTTP文件上传与简历块文件上传、简历、Net、ASP

2023-09-04 03:13:40 作者:⊙ 海誓三盟亦分開

请参见问题:http://stackoverflow.com/questions/2062852/resume-in-upload-file-control

现在找到上述问题的解决方案,我想在这工作,开发用户控件,它可以恢复一个HTTP文件上传过程。

Now to find a solution for the above question, I want to work on it and develop a user control which can resume a HTTP File Upload process.

对于这一点,我将在服务器上创建一个临时文件,直到上传完成。一旦上传完全做到,那么只需将其保存到所需的位置。

For this, I'm going to create a temporary file on server until the upload is complete. Once the uploading is done completely then will just save it to the desired location.

我想到的方法是:

创建一个独特的名字的临时文件(可能是GUID)的服务器上。 在读取文件的数据块,并把它添加到服务器上的这个临时文件。 在继续分3步,直到到达EOF。 现在,如果连接丢失或暂停按钮用户点击,文件的写入被停止和临时文件不会被删除。 再次点击恢复或重新上传同一文件将检查服务器上,如果该文件存在,并且用户是否恢复覆盖。 (不知道如何检查,如果是同一个文件。此外,安踏将来自客户端的大块服务器。) 点击恢复会从那里被要求上传,并开始将它添加到服务器上的文件。 (同样不知道如何做到这一点。) Create a temporary file with a unique name (may be GUID) on the server. Read a chunk of file and append it to this temp file on the server. Continue step 1 to 3 until EOF is reached. Now if the connection is lost or user clicks on pause button, the writing of file is stopped and the temporary file is not deleted. Clicking on resume again or uploading the same file again will check on the server if the file exists and user whether to resume or to overwrite. (Not sure how to check if it's the same file. Also, how to step sending the chunks from client to server.) Clicking on resume will start from where it is required to be uploaded and will append that to the file on the server. (Again not sure how to do this.)

问题:

难道这些步骤正确的要达到的目标?还是需要一些修改? 在我不知道如何执行所有这些步骤。 :-(极品思路,链接...

任何帮助AP preciated ...

Any help appreciated...

推荐答案

你所想是不容易的,但它是可行的。请遵循以下准则:

What you are trying is not easy, but it is doable. Follow these guidelines:

2写入功能在客户端使用AJAX:

Write 2 functions on the client side using ajax: getUploadedPortionFromServer(文件名) - 这将要求服务器如果该文件存在,它应该从服务器获取具有以下信息的XML响应: 布尔(存在/不存在)尺寸(字节) MD5(字符串) 该功能也将在其上运行的服务器上了本地文件一样大小的MD5, 如果MD5是一样的,你可以继续从点就停止,发送 ELSEIF不一样或大小== 0,重新开始。 uploadFromBytes(X) - 将取决于第一个函数 getUploadedPortionFromServer(filename) - This will ask the server if the file exists, and it should get an xml response from the server with the following info: boolean(exist/not exist), size(bytes), md5(string) The function will also run an md5 on the same size it got from the server on the local file, If the md5 is the same, you can continue sending from the point it was stopped, elseif not the same or size == 0, start over. uploadFromBytes(x) - Will depend on the 1st function.

在服务器上,您必须编写配套功能,将检查所需要的东西,并通过发送XML到客户端的响应。

On the server you have to write matching functions, which will check the needed stuff, and send the response via XML to the client.

在为了有不同的文件名,你应该使用某种形式的用户标注。 是用户登录到你的服务器?如果是的话,使用thier用户名添加到文件名的哈希值,这将帮助你区分文件之间。 如果没有,使用Cookie。
 
精彩推荐
图片推荐