Topic: 'blob' filename

When I upload a file in multipart mode using the HTML 5 runtime, the filename is lost and the browsers just sends:

-----------------------------1117779921282589049853871300 Content-Disposition: form-data; name="file"; filename="blob"

This problem occurs when using FireFox 7.01 as well as Chromium 12.0 although I get hash appended to the filename e.g.: "blob891902399ef9a9b1123de9a". I tried it on a windows VM image and it also gave me 'blob' as filename. I also uploaded a file on: http://www.plupload.com/example_all_runtimes.php and noticed filename="blob" in the headers aswell.

Anyone else has this problem?

Re: 'blob' filename

We are having the exact same problem, and it has started causing A LOT of problems. Reverting to an older Plupload version may be in order.

Re: 'blob' filename

Turning off chunking solves the problem, but you lose out on the benefits of chunking.

Re: 'blob' filename

So it's save to say that this is a bug, I'll file a bug report.

Re: 'blob' filename

This is not a bug. This is how browsers work in html5 mode at the moment, so you shouldn't rely on $_FILES['file']['name'] if you use chunking and html5 runtime. There is addition to the current W3C XMLHttpRequest Level 2 Editor's Draft that at some point they will give us ability to control the filename argument, but that's not a case currently.

If you want to see your issue fixed, do not report it here, do it on - GitHub.

Re: 'blob' filename

Thanks for the info davit. How do you recommend we get the file name if we should not rely on $_FILES['file']['name']?

7 (edited by racingcow 2013-04-23 18:14:16)

Re: 'blob' filename

Sorry for posting to such an old thread, but I thought this might help someone. The way I got around this was to handle the BeforeUpload event, and in that handler capture the original filename and pass it in as a multipart parameter...

function onUploaderBeforeUpload(up, file) {
        up.settings.multipart_params = {
            filename: file.name
        };
    }

On the server side, you should be able to read that out of the custom filename multipart param form data instead of the file one that PLUpload puts in there. Your request should look something like this after adding the JavaScript above...

Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: http://myserver/myapp/
Content-Length: 1049326
Content-Type: multipart/form-data; boundary=---------------------------179791422927594
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache

-----------------------------179791422927594
Content-Disposition: form-data; name="name"

p17ortnk0c19ctr2t6qr11gb90p3.mp4
-----------------------------179791422927594
Content-Disposition: form-data; name="chunk"

0
-----------------------------179791422927594
Content-Disposition: form-data; name="chunks"

72
-----------------------------179791422927594
Content-Disposition: form-data; name="filename"

Star Wars Call Me Maybe.mp4
-----------------------------179791422927594
Content-Disposition: form-data; name="file"; filename="blob"
Content-Type: application/octet-stream

...

Re: 'blob' filename

function onUploaderBeforeUpload(up, file) {
        up.settings.multipart_params = {
            filename: file.name
        };
    }


where i have put this function in code

9 (edited by gongli 2013-06-24 09:39:58)

Re: 'blob' filename

nilesh.0604 wrote:

function onUploaderBeforeUpload(up, file) {
        up.settings.multipart_params = {
            filename: file.name
        };
    }


where i have put this function in code

This function name maynot onUploaderBeforeUpload but BeforeUpload

10 (edited by damike 2013-09-02 21:40:47)

Re: 'blob' filename

So i have disabled chunking and will only use the resize of html5 but still get blog as filename. any suggestions? smile

Edit: using the actual v2

Re: 'blob' filename

I get blob as a file name
any suggestions?

Re: 'blob' filename

@pepe, you probably are using upload handler of your own, that doesn't respect $_REQUEST['name'] argument. We always pass original filename in it when it is not possible to alter the multipart message.

If you want to see your issue fixed, do not report it here, do it on - GitHub.

Re: 'blob' filename

Plupload is not working on IE. It is giving me the following error:

Webpage error details
User Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/6.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; MS-RTC LM 8; .NET4.0E; InfoPath.3; EIE10;ENUSMCM)
Timestamp: Fri, 20 Dec 2013 14:53:11 UTC

Message: Unable to set property 'exec' of undefined or null reference
Line: 48
Char: 3
Code: 0
URI: XXXXXXXXXXXXXXXXXXXXXXXXXXXX

Message: Unable to set property 'isOccupied' of undefined or null reference
Line: 48
Char: 3
Code: 0
URI: XXXXXXXXXXXXXXXXXXXXXXXX

Message: Unable to get property 'SetReturnValue' of undefined or null reference
Line: 1
Char: 212
Code: 0
URI: XXXXXXXXXXXXXXXXXXXXXXXXX

Message: Invalid pointer
Line: 15
Char: 11368
Code: 0
URI: ../javascript/plupload.full.min.js

Regards,
Umesh

Re: 'blob' filename

pepe wrote:

I get blob as a file name
any suggestions?


What i did to solve this was in the javascript for the uploader, I added this

 // Post init events, bound after the internal events
                        init: {
                            PostInit: function () {
                                // Called after initialization is finished and internal event handlers bound
                                //    log('[PostInit]');

                                document.getElementById('uploadfiles').onclick = function () {
                                    uploader.start();
                                    return false;
                                };
                            },

                            BeforeUpload: function (up, file) {
                                // Called right before the upload for a given file starts, can be used to cancel it if required
                                up.settings.multipart_params = {
                                    filename: file.name
                                };
                            },

                            UploadComplete: function (up, files) {
                                // Called when all files are either uploaded or failed
                                //        log('[UploadComplete]');
                            }
                        }

And then in the API, i added a variable to hold the filename i passed through the BeforeUpload function. I also had a variable to hold chunk and chunks. I then wrote the whole file uploaded into a txt file. SO i called every file uploaded test.txt. I Then check after each write to the file if that is the last chunk, this can be achived by testing if chunk+1 = chunks or chunk=chunks-1.

If this is true, then i renamed test.txt as the filename original filename. This worked brilliantly. For clarity below is the ASP API I used.

<%
' Timeout di massimo tempo di esecuzione = 100 minuti
Dim FS, serverpath, fName, chunk, chunks, strRename, RealExtension, changefrom

'on error resume next
Server.ScriptTimeout = 6000
  
'caching'
response.addheader "Cache-Control", "no-store, no-cache, must-revalidate"
response.addheader "Cache-Control", "post-check=0, pre-check=0"
response.addheader "Pragma", "no-cache"
 
' Recupero il numero di byte ricevuti
ByteRicevuti = Request.TotalBytes
DatiRicevuti = Request.BinaryRead(ByteRicevuti)
 
For i = 1 To lenB(DatiRicevuti)
  FileBinario = FileBinario & chr(ascB(midB(DatiRicevuti,i,1)))
Next
 
FirmaFile = left(FileBinario,instr(FileBinario,"" & vbCrLf)-1)
ArrPezzi  = split(FileBinario,FirmaFile)
 
 
for pezzo = 1 to ubound(ArrPezzi)-1
      Inizio = instr(ArrPezzi(pezzo),"" & vbCrLf & "" & vbCrLf)
      Intestazione = left(ArrPezzi(pezzo),Inizio-1)
      Inizio = Inizio + len("" & vbCrLf) + len("" & vbCrLf)
      ContenutoFile = mid(ArrPezzi(pezzo),Inizio,len(ArrPezzi(pezzo))-Inizio-1)
    
      if instr(ArrPezzi(pezzo), "name=""filename") > 0 Then
         fName = replace(mid(ArrPezzi(pezzo), instr(ArrPezzi(pezzo), "filename")+8, len(ArrPezzi(pezzo))),"""","")        
      end if

      if instr(ArrPezzi(pezzo), "name=""chunk""") > 0 Then
         chunk = replace(mid(ArrPezzi(pezzo), instr(ArrPezzi(pezzo), "chunk")+5, len(ArrPezzi(pezzo))),"""","")        
      end if

      if instr(ArrPezzi(pezzo), "name=""chunks""") > 0 Then
         chunks = replace(mid(ArrPezzi(pezzo), instr(ArrPezzi(pezzo), "chunks")+6, len(ArrPezzi(pezzo))),"""","")        
      end if
next
 
'stop
 
if instr(Intestazione,"file") > 0 then
 
    i = InStr(Intestazione, "filename=")
      j = InStr(i + 10, Intestazione, chr(34))
       
      NomeUpload = Mid(Intestazione, i + 10, j - i - 10)
      i = InStrRev(NomeUpload,"\")
       
      if i <> 0 then
        NomeFile = mid(NomeUpload, i + 1)
      else   
        NomeFile = NomeUpload
      end if
             
           if NomeFile <> "" then
           dim FSO
       Set FSO = CreateObject("Scripting.FileSystemObject")
       Upload1 = True
       DimensioneFile1 = len(ContenutoFile)
       EstensioneFile1 = right(ContenutoFile,3)

       'Check to see there is a temp folder created for this section and it not create it
       Set FS=Server.CreateObject("Scripting.FileSystemObject")
       If FS.FolderExists(Server.MapPath(".") & "\uploadfiles\TmpAttachments") = False Then
           FS.CreateFolder(Server.MapPath(".") & "\uploadfiles\TmpAttachments")
       End If

       If FS.FolderExists(Server.MapPath(".") & "\uploadfiles\TmpAttachments\Session" & Session("ID") ) = False Then
           FS.CreateFolder(Server.MapPath(".") & "\uploadfiles\TmpAttachments\Session" & Session("ID"))
       End If

       If FS.FolderExists(Server.MapPath(".") & "\uploadfiles\TmpAttachments\Session" & Session("ID") & "\WF" ) = False Then
           FS.CreateFolder(Server.MapPath(".") & "\uploadfiles\TmpAttachments\Session" & Session("ID")  & "\WF" )
       End If    

       'Store the path in a vriable
       serverpath=Server.MapPath(".") & "\uploadfiles\TmpAttachments\Session" & Session("ID") & "\WF\" 

        NomeFile1 = serverpath & "test.txt"  
        'NomeFile1 = "uploads\" & NomeFile            'salvo i file nella directory uploads
                 
        if left(ContenutoFile,4) = "ÿØÿà"  then        'Has the file already been created                 
            Set textStream = FSO.CreateTextFile(NomeFile1, True, False)
        else       
            Set textStream = FSO.OpenTextFile(NomeFile1, 8, True)               
        end if
 
          textStream.Write ContenutoFile
 
        textStream.Close
        Set textStream = Nothing
        
        if CInt(chunk) = CInt(chunks)-1 Then
            fName = Replace(fName, vbCrLf, "")
            RealExtension = mid(fname,instr(fname,".")+1, len(fname))
            RealExtension = Replace(RealExtension, vbCrLf, "")
            changefrom = "txt"
            strRename = serverpath & fName
            FSO.GetFile(NomeFile1).Name = replace(FSO.GetFile(NomeFile1).Name, changefrom, CStr(RealExtension))
            NomeFile1 = replace(NomeFile1, changefrom, CStr(RealExtension))
            if fso.FileExists(strRename) Then
                fName = replace(fName,".", "1.")
            end if
            FSO.GetFile(NomeFile1).Name = fName
        end if
        Set FSO = Nothing
      end if      
end if
 
%>