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

MultipartFormDataParser using UploadedFile does not work #17037

Closed
Nuffic opened this issue Jan 13, 2019 · 2 comments
Closed

MultipartFormDataParser using UploadedFile does not work #17037

Nuffic opened this issue Jan 13, 2019 · 2 comments
Labels
Milestone

Comments

@Nuffic
Copy link

Nuffic commented Jan 13, 2019

What steps will reproduce the problem?

  1. use yii\web\MultipartFormDataParser as a request parser
  2. upload file using PATCH method
  3. use UploadedFile to instanciate the file

What is the expected result?

When using UploadedFile::saveAs() file is saved into specified directory.

What do you get instead?

Since it uses php-s move_uploaded_file() or is_uploaded_file() which check if php itself dealt with uploaded file (which it didn't), file is not saved.

Additional info

yii\web\MultipartFormDataParser deals with $_FILES itself not php.

Q A
Yii version 2.0.15.1

Relates to #6996 but is not the same.

@samdark samdark added type:bug Bug status:ready for adoption Feel free to implement this issue. labels Jan 14, 2019
@mihaivarga
Copy link

We attempted an upgrade from 2.0.14. For us this seems to be happening with latest #2.0.18 version using POST also. Any advice? File do not get saved, type not identified and files shows error 3 and validation trigger the file type missing. All works fine when we downgrade to 2.0.14.1.

@alexkart
Copy link
Contributor

alexkart commented Jun 13, 2019

@Nuffic it's mentioned in the documentation https://www.yiiframework.com/doc/api/2.0/yii-web-multipartformdataparser

Note: although this parser fully emulates regular structure of the $_FILES, related temporary files, which are available via tmp_name key, will not be recognized by PHP as uploaded ones. Thus functions like is_uploaded_file() and move_uploaded_file() will fail on them. This also means yii\web\UploadedFile::saveAs() will fail as well.

@samdark samdark added status:under development Someone is working on a pull request. and removed status:ready for adoption Feel free to implement this issue. labels Dec 12, 2019
@samdark samdark added this to the 2.0.32 milestone Jan 14, 2020
@samdark samdark removed the status:under development Someone is working on a pull request. label Jan 14, 2020
yus-ham added a commit to yus-ham/yii2 that referenced this issue Jan 15, 2020
…ltipart forms, add path alias support for UploadFile::saveAs()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants