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

[feature request] XMLHttpRequest2 file uploads #4870

Closed
Sorien opened this issue Jul 12, 2012 · 10 comments
Closed

[feature request] XMLHttpRequest2 file uploads #4870

Sorien opened this issue Jul 12, 2012 · 10 comments

Comments

@Sorien
Copy link
Contributor

Sorien commented Jul 12, 2012

Add support for XHR2 file uploads

reference:
http://www.alexanderschnitzler.de/2011/06/howto-build-an-html5-file-uploader-with-ajax/
http://www.w3.org/TR/XMLHttpRequest/

expected result:
Symfony\Component\HttpFoundation\Request FileBag should contain uploaded file

@piotrantosik
Copy link
Contributor

+1

3 similar comments
@yoann-losbar
Copy link

+1

@guillaumepotier
Copy link

+1

@coma
Copy link
Contributor

coma commented Feb 21, 2013

+1

@ghost
Copy link

ghost commented Feb 23, 2013

Someone should make a PR.

@kepten
Copy link
Contributor

kepten commented Mar 21, 2013

Hi,
I'm ready to work on this PR but first I need to clarify if it is still a valid feature request. I have found some articles which shows how to upload a single file (http://updates.html5rocks.com/2012/04/Processing-XHR2-file-uploads-in-PHP) or multiple files (https://github.com/Integralist/XHR2-Multiple-File-Upload--with-PHP-) using XHR2 but they are both posting the files inside a FormData object (not the JavaScript File object) which means $_FILES gets populated as it should.
My question is: is there a valid use case of using the File object instead of the more comfortable FormData?

@kepten
Copy link
Contributor

kepten commented Mar 26, 2013

@Sorien
Copy link
Contributor Author

Sorien commented Apr 22, 2013

it has very low priority because, you can create something like this

        var formdata = new FormData();
        formdata.append("fieldName", file);

        var xhr = new XMLHttpRequest();
        xhr.open("POST", "url", true);

        xhr.send(formdata);

but as far as it's part of spec's it should be supported

@kepten
Copy link
Contributor

kepten commented Apr 22, 2013

The spec says nothing about how to implement direct BLOB uploading on the server side (e.g. which HTTP header stores the filename, size, etc.) which makes this very client-side dependent. The original request was to populate the FileBag property, but my opinion is that this property should handle only files uploaded as part of a form and should not include a custom implementation of this XHR2 mechanism.
But if someone wants to use this feature, he/she should be able to use $this->get("request")->getContent(true) (instead of php://input) and handle the upload manually.

@javiereguiluz
Copy link
Member

I'm closing this issue because in 3 years it hasn't registered any activity. If this feature is still desired, a new issue can be created to discuss about including it in Symfony 3. Thank you!

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

No branches or pull requests

7 participants