I have created a new project and i have follow this steps:
1- Create a new webapplication for VB via Visual Studio 2010 Ultimate
2- Install AjaxControlToolkit 7.1213 via NuGet Packages
3- Add the <httpHandlers> to system.web
4- Create a new aspx page and add the AjaxFileUpload
ASPX File
```
<ajaxToolkit:ToolkitScriptManager runat="Server" />
<ajaxToolkit:AjaxFileUpload ID="AjaxFileUpload1" runat="server" />
```
ASPX.VB file
```
Private Sub AjaxFileUpload1_UploadComplete(sender As Object, e As AjaxControlToolkit.AjaxFileUploadEventArgs) Handles AjaxFileUpload1.UploadComplete
Dim strPath As String = MapPath("~/upload/") + Path.GetFileName(e.FileName)
AjaxFileUpload1.SaveAs(strPath)
End Sub
```
And When a i upload a file this file arrives to the server corrupted if has special chars on this name like º,ª,ã,õ.
Whats is happening??
This is the link with the all project:
[https://dl.dropboxusercontent.com/u/4566444/FileUploadFinalTest.rar](https://dl.dropboxusercontent.com/u/4566444/FileUploadFinalTest.rar)
Thanks, and sorry for my bad English
Comments: It's the same problem in : http://ajaxcontroltoolkit.codeplex.com/workitem/27622 http://ajaxcontroltoolkit.codeplex.com/workitem/27500 And there is a solution (not realy clean...). If you download Ajax Control Toolkit Code source, You will find a javascript file named : AjaxFileUpload.ProcessorHtml5.pre.js The problem is in the upload funtion : this.upload = function (fileItem) { ... If I want to upload a file named : 20140710Ré.doc On upload, If you take look at the POST Request : -----------------------------138715451195 Content-Disposition: form-data; name="act-file-data"; filename="20140710Ré.doc" Content-Type: application/msword The "é" character is not interpreted in the request and that's the problem. A solution is to remove these characters. The original code : // preparing upload data var blob = fileItem.get_inputElementValue(), fileName = fileItem._fileName, chunked = fileItem._slices && (fileItem._slices > 0), firstChunk = fileItem._sliceIndex == 0; ... xhrReq.open("POST", control._uploadUrl + '?contextKey=' + control._contextKey + '&fileId=' + id + '&fileName=' + fileName + '&chunked=' + (chunked ? "true" : "false") + '&firstChunk=' + firstChunk + '&storeToAzure=' + control.get_storeToAzure() + '&acn=' + control.get_azureContainerName(), true); form.append("act-file-data", blob, fileName); xhrReq.send(form); The new code : // preparing upload data var blob = fileItem.get_inputElementValue(), fileName = fileItem._fileName, chunked = fileItem._slices && (fileItem._slices > 0), firstChunk = fileItem._sliceIndex == 0; //HERE you change the filename - need a cleaner solution var fileNameDec = decodeURIComponent(fileItem._fileName); var fileNameDecProper = fileNameDec.replace(/[éèêë]/g, 'e').replace(/[àâä]/g, 'a').replace(/[îï]/g, 'i').replace(/[ùûü]/g, 'u').replace(/[ôö]/g, 'o'); //.replace(/[^a-z.A-Z0-9]/g, ''); var properFileName = encodeURIComponent(fileNameDecProper); var fileName = properFileName; var chunked = fileItem._slices && (fileItem._slices > 0); var firstChunk = fileItem._sliceIndex == 0; ... //HERE you pass the clean filename xhrReq.open("POST", control._uploadUrl + '?contextKey=' + control._contextKey + '&fileId=' + id + '&fileName=' + properFileName + '&chunked=' + (chunked ? "true" : "false") + '&firstChunk=' + firstChunk + '&storeToAzure=' + control.get_storeToAzure() + '&acn=' + control.get_azureContainerName(), true); //HERE you pass the clean filename form.append("act-file-data", blob, properFileName); xhrReq.send(form); If you take look at the new POST Request : -----------------------------16299844722445 Content-Disposition: form-data; name="act-file-data"; filename="20140710Re.doc" Content-Type: application/msword And the file is no more corrupted !
1- Create a new webapplication for VB via Visual Studio 2010 Ultimate
2- Install AjaxControlToolkit 7.1213 via NuGet Packages
3- Add the <httpHandlers> to system.web
4- Create a new aspx page and add the AjaxFileUpload
ASPX File
```
<ajaxToolkit:ToolkitScriptManager runat="Server" />
<ajaxToolkit:AjaxFileUpload ID="AjaxFileUpload1" runat="server" />
```
ASPX.VB file
```
Private Sub AjaxFileUpload1_UploadComplete(sender As Object, e As AjaxControlToolkit.AjaxFileUploadEventArgs) Handles AjaxFileUpload1.UploadComplete
Dim strPath As String = MapPath("~/upload/") + Path.GetFileName(e.FileName)
AjaxFileUpload1.SaveAs(strPath)
End Sub
```
And When a i upload a file this file arrives to the server corrupted if has special chars on this name like º,ª,ã,õ.
Whats is happening??
This is the link with the all project:
[https://dl.dropboxusercontent.com/u/4566444/FileUploadFinalTest.rar](https://dl.dropboxusercontent.com/u/4566444/FileUploadFinalTest.rar)
Thanks, and sorry for my bad English
Comments: It's the same problem in : http://ajaxcontroltoolkit.codeplex.com/workitem/27622 http://ajaxcontroltoolkit.codeplex.com/workitem/27500 And there is a solution (not realy clean...). If you download Ajax Control Toolkit Code source, You will find a javascript file named : AjaxFileUpload.ProcessorHtml5.pre.js The problem is in the upload funtion : this.upload = function (fileItem) { ... If I want to upload a file named : 20140710Ré.doc On upload, If you take look at the POST Request : -----------------------------138715451195 Content-Disposition: form-data; name="act-file-data"; filename="20140710Ré.doc" Content-Type: application/msword The "é" character is not interpreted in the request and that's the problem. A solution is to remove these characters. The original code : // preparing upload data var blob = fileItem.get_inputElementValue(), fileName = fileItem._fileName, chunked = fileItem._slices && (fileItem._slices > 0), firstChunk = fileItem._sliceIndex == 0; ... xhrReq.open("POST", control._uploadUrl + '?contextKey=' + control._contextKey + '&fileId=' + id + '&fileName=' + fileName + '&chunked=' + (chunked ? "true" : "false") + '&firstChunk=' + firstChunk + '&storeToAzure=' + control.get_storeToAzure() + '&acn=' + control.get_azureContainerName(), true); form.append("act-file-data", blob, fileName); xhrReq.send(form); The new code : // preparing upload data var blob = fileItem.get_inputElementValue(), fileName = fileItem._fileName, chunked = fileItem._slices && (fileItem._slices > 0), firstChunk = fileItem._sliceIndex == 0; //HERE you change the filename - need a cleaner solution var fileNameDec = decodeURIComponent(fileItem._fileName); var fileNameDecProper = fileNameDec.replace(/[éèêë]/g, 'e').replace(/[àâä]/g, 'a').replace(/[îï]/g, 'i').replace(/[ùûü]/g, 'u').replace(/[ôö]/g, 'o'); //.replace(/[^a-z.A-Z0-9]/g, ''); var properFileName = encodeURIComponent(fileNameDecProper); var fileName = properFileName; var chunked = fileItem._slices && (fileItem._slices > 0); var firstChunk = fileItem._sliceIndex == 0; ... //HERE you pass the clean filename xhrReq.open("POST", control._uploadUrl + '?contextKey=' + control._contextKey + '&fileId=' + id + '&fileName=' + properFileName + '&chunked=' + (chunked ? "true" : "false") + '&firstChunk=' + firstChunk + '&storeToAzure=' + control.get_storeToAzure() + '&acn=' + control.get_azureContainerName(), true); //HERE you pass the clean filename form.append("act-file-data", blob, properFileName); xhrReq.send(form); If you take look at the new POST Request : -----------------------------16299844722445 Content-Disposition: form-data; name="act-file-data"; filename="20140710Re.doc" Content-Type: application/msword And the file is no more corrupted !