Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

html5 firefox 7.01 and chromium 12 #398

Closed
Visualq opened this issue Oct 4, 2011 · 17 comments
Closed

html5 firefox 7.01 and chromium 12 #398

Visualq opened this issue Oct 4, 2011 · 17 comments

Comments

@Visualq
Copy link

Visualq commented Oct 4, 2011

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.

I'm running ubuntu 11.04 64bit

@Callipepla
Copy link

Looks like they documented the change here:

https://developer.mozilla.org/en/DOM/XMLHttpRequest/FormData#Gecko_notes

Prior to Gecko 7.0 (Firefox 7.0 / Thunderbird 7.0 / SeaMonkey 2.4) , if you specified a Blob as the data to append to the object, the filename reported in the "Content-Disposition" HTTP header was an empty string; this resulted in errors being reported by some servers. Starting in Gecko 7.0, the filename "blob" is sent.

@Visualq
Copy link
Author

Visualq commented Oct 4, 2011

'Prior to' I'm using FF 7.0 so it shouldn't be happening right?

On 10/04/2011 10:18 PM, Charles Capps wrote:

Looks like they documented the change here:

https://developer.mozilla.org/en/DOM/XMLHttpRequest/FormData#Gecko_notes

Prior to Gecko 7.0 (Firefox 7.0 / Thunderbird 7.0 / SeaMonkey 2.4) , if you specified a Blob as the data to append to the object, the filename reported in the "Content-Disposition" HTTP header was an empty string; this resulted in errors being reported by some servers. Starting in Gecko 7.0, the filename "blob" is sent.

@jayarjo
Copy link
Contributor

jayarjo commented Oct 5, 2011

filename="blob" is expected behavior, why do you think it is lost? This should be happening only when you have chunking enabled, so every chunk will be sent this way. The problem with Geckos prior to 7 was that they were sending empty string in filename (like filename=""), which caused some servers to not interpret this properly, but filename="blob" is ok. You shouldn't have any problems with this. If you have some, then maybe describe your usage case in a bit more detail.

@jayarjo
Copy link
Contributor

jayarjo commented Oct 5, 2011

Chromium 12.0 should not be having any problems at all, so - yes, something odd happens. Please provide more details - config, your code, your expectations.

@chrisuae
Copy link

chrisuae commented Oct 5, 2011

I'm having the same problem on Chrome 14 using html5. It still works with flash. The problem is the 'name' in $_REQUEST is returning a Blob.... name instead of the actual filename. So what you end up with is a separate Blob file for each chunk instead of having each Blob file appended to the single server-side file with the actual filename.

// Get parameters
$chunk = isset($_REQUEST["chunk"]) ? $_REQUEST["chunk"] : 0;
$chunks = isset($_REQUEST["chunks"]) ? $_REQUEST["chunks"] : 0;
$fileName = isset($_REQUEST["name"]) ? $_REQUEST["name"] : ''; // in html5 with Chrome 14, this returns the same as "chunk"

@jayarjo
Copy link
Contributor

jayarjo commented Oct 5, 2011

@chrisuae name in $_REQUEST, or name in $_FILES?..

@jayarjo
Copy link
Contributor

jayarjo commented Oct 5, 2011

Chrome 12, Chrome 14... I'm using Chrome 15... who said IE is nightmare?

@Visualq
Copy link
Author

Visualq commented Oct 5, 2011

Ok, here's a var dump

$_POST:
array(3) {
["name"]=>
string(32) "p16bapfgrm16n11d81rshpqr5um4.jpg"
["chunk"]=>
string(1) "1"
["chunks"]=>
string(1) "2"
}

$_FILES:
array(1) {
["file"]=>
array(5) {
["name"]=>
string(4) "blob"
["type"]=>
string(24) "application/octet-stream"
["tmp_name"]=>
string(14) "/tmp/phpg2nhR5"
["error"]=>
int(0)
["size"]=>
int(545894)
}
}

Basically the configuration doesn't matter I get the same problem on: http://www.plupload.com/example_all_runtimes.php

My expectations, as it used to work, is that
["name"]=>
string(4) "blob"
contains the actual filename instead of 'blob'

@jayarjo
Copy link
Contributor

jayarjo commented Oct 5, 2011

I'm afraid there is no way around this. I wish there was, but there's none. In case you manage to find one, let us know. We are open to suggestions.

Setting filename as blob when sending chunks is actually current W3C recommendation. There's a plan to make it possible to pass filename as third parameter. But I've not seen any support for this in current browsers. By now you should not rely on $_FILES[...][name]. Use $_REQUEST['name'].

@Visualq
Copy link
Author

Visualq commented Oct 5, 2011

On 10/05/2011 09:51 PM, Davit Barbakadze wrote:

I'm afraid there is no way around this. I wish there was, but there's none. In case you manage to find one, let us know. We are open to suggestions.

Setting filename as blob when sending chunks is actually currentW3C recommendation. There's a plan to make it possible to pass filename as third parameter. But I've not seen any support for this in current browsers.

How about fetching the selected filename and add it as an argument just
before uploading, that should be possible?

@jayarjo
Copy link
Contributor

jayarjo commented Oct 5, 2011

In your case I see that you got unique_names option set to true. That's why you get those cryptic filenames in $_REQUEST['name']. (I guess that's what you intended, right?). If for some reason you still require original filename you can pass it as one of the multipart_params yourself, let's say add it on BeforeUpload event.

@Visualq
Copy link
Author

Visualq commented Oct 5, 2011

On 10/05/2011 10:08 PM, Davit Barbakadze wrote:

In your case I see that you got unique_names option set to true. That's why you get those cryptic filenames in $_REQUEST['name'](I guess that what you intended, right?). If for some reason you require original filename you can pass it as one of the multipart_params yourself, let's say add it on BeforeUpload event.

Ok I solved it by adding the filename as a parameter to the url the file
is being uploaded. Also had to determine the content-type, but it works
now. Thanks for the help!

@Afraithe Afraithe closed this as completed Oct 6, 2011
@enterpidev
Copy link

blob filename issue:
When I upload a file in multipart mode using the HTML 5 runtime, the filename is lost and the browsers just sends
file name as blob, content type as application/octet-stream
I am using safari 6.0.5 in MAC os system. In windows it is working fine.

@georgever
Copy link

I had the same problem it was the resize option. remove that from cofiguration and should be fine

@jayarjo
Copy link
Contributor

jayarjo commented Dec 11, 2013

Blob (+ some gibberish) is a normal thing if you are awaiting filename from $_FILES['file']['name'], that's why we send original file name with every chunk in $_REQUEST['name'].

@enlatis
Copy link

enlatis commented Jun 17, 2014

Any update on this? Using PLUpload with wordpress/gravity forms implementation. Try to figure out how to get it to take the original filename, and not blob. From upload.php:

    $chunk  = isset($_REQUEST["chunk"]) ? intval($_REQUEST["chunk"]) : 0;
    $chunks = isset($_REQUEST["chunks"]) ? intval($_REQUEST["chunks"]) : 0;

    $file_name = isset($_REQUEST["name"]) ? $_REQUEST["name"] : '';
    $field_id  = rgpost("field_id");
    $field     = GFFormsModel::get_field($form, $field_id);

Here are my parameters:

                    $plupload_init = array(
                        'runtimes' => 'html5,flash,html4',
                        'browse_button' => $browse_button_id,
                        'container' => $container_id,
                        'drop_element' => $drag_drop_id,
                        'filelist' => $file_list_id,
                        'unique_names' => true,
                        'file_data_name' => 'file',
                        'chunk_size' => '50mb',
                        'max_retries' => 3,
                        'url' => $upload_action_url,
                        'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'),
                        'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'),
                        'filters' => array(
                            'mime_types' => array(array('title' => __( 'Allowed Files', 'gravityforms' ), 'extensions' => $allowed_extensions)),
                            'max_file_size' => $max_upload_size . 'b'
                        ),
                        'multipart' => true,
                        'urlstream_upload' => false,
                        'multipart_params' => array(
                            "form_id" => $form_id,
                            "field_id" => $id
                        ),
                        'gf_vars' => array(
                            'max_files' => $max_files,
                            'message_id' => $messages_id,
                            'disallowed_extensions' => $disallowed_extensions
                        )
                    );

@khanzadimahdi
Copy link

i have done it by adding filename into each chunk using "BeforeChunkUpload" method , here is my code

init:{
       BeforeChunkUpload: function(uploader, file, post, currentBlob, currentOffset) {
              currentBlob.name=file.name;
       },
},

then you have the filename in each chunk instead of that shit "blob" name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants