I have used the ajax file uploader with the progress bar on .net webforms v4. Everything works fine until the uploaded file is deleted by a user. I have an html button triggers the deletion through a json function. When the delete button is clicked, the
uploaded file and its folder are deleted sucessfully. When a second file is uploaded, the progress bar runs but no file is uploaded or saved... If the delete button is NOT clicked, then the uploader uploads the second file successfully...
I would appreciate any help.
The delete function is as follows:
$.ajax({
type: "POST",
url: "../FileUpload.asmx/DeleteUploadedFile",
data: "{dirPath: 'xxxxxx'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
alert('success');
}
});
The File Upload cs is as below:
[WebMethod]
public void DeleteUploadedFile(string dirPath)
{
Directory.Delete(HttpContext.Current.Server.MapPath(dirPath), true);
}
If the delete button is NOT clicked, then the uploader uploads the second file successfully...
According to your description, i suppose that you delete the directory path of files when you click delete button, then you save the files , but the directory path not exists.
i would suggest you try adding the codes below when you save the files:
if it is not helpful for you, you can provide any additional codes(for example: add, create etc.) or
markup page related to this issue? It may be a bit easier to resolve if it can be easily reproduced.
Thank you for your understanding.
We are trying to better understand customer views on social support experience. Click HERE to participate the survey. Thanks!
Member
1 Points
15 Posts
Ajax File Upload problem after deleting a file ...
Feb 10, 2014 06:13 AM|B10|LINK
Hello,
I have used the ajax file uploader with the progress bar on .net webforms v4. Everything works fine until the uploaded file is deleted by a user. I have an html button triggers the deletion through a json function. When the delete button is clicked, the uploaded file and its folder are deleted sucessfully. When a second file is uploaded, the progress bar runs but no file is uploaded or saved... If the delete button is NOT clicked, then the uploader uploads the second file successfully...
I would appreciate any help.
The delete function is as follows:
All-Star
15648 Points
2151 Posts
Re: Ajax File Upload problem after deleting a file ...
Feb 10, 2014 11:48 PM|Happy Chen - MSFT|LINK
HI,
According to your description, i suppose that you delete the directory path of files when you click delete button, then you save the files , but the directory path not exists.
i would suggest you try adding the codes below when you save the files:
please refer to the link for details:
http://msdn.microsoft.com/en-us/library/fxeahc5f(v=vs.110).aspx
if it is not helpful for you, you can provide any additional codes(for example: add, create etc.) or markup page related to this issue? It may be a bit easier to resolve if it can be easily reproduced.
Thank you for your understanding.