Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

[BUG] This fix allows the upload of same filenames in input type file #13

Merged
merged 1 commit into from
Feb 16, 2016
Merged

[BUG] This fix allows the upload of same filenames in input type file #13

merged 1 commit into from
Feb 16, 2016

Conversation

codisart
Copy link
Contributor

For example, Safari on IOS gives the name image.jpg for pictures from the gallery
In the present situation, the first files would be overriden by the last file with the same name.
And the getValue of these inputs will return the same fileName with no really mean to identify it.
With the use of the unique name from PHP $_FILES in the name column of the $_files array of the Http adapter, the files will be unique and easily identifiable.

I have adjusted the unit test for the File/Transfer/Adapter/HttpTest::testMultiFiles() method and added one for a same name case.

First, the $_FILES is mocked with the implication that the "name" value can be a path with more than one directory. Shouldn't it be only a filename like picture.jpg, document.docx or script.php ?

Secondly, the "tmp_name" value doesn't seem to be mocked properly, or the format %TMP_DIRECTORY%/php123456 can be overriden ?

Codisart

For example, Ios Safari gives the name image.jpg for pcitures from the gallery
In the present situation, the first files would be overriden by the last file with the same name.
And the getValue of these inputs will return the same fileName with no really mean to identify it.
With the use of the unique name from PHP $_FILES in the name column of the $_files array of the Http adapter, the files will be unique and easily identifiable.

- Fix the unit tests and add a new one for the same filename case.
@codisart codisart changed the title [BUG] This commit allows the upload of same filenames in input type file [BUG] This fix allows the upload of same filenames in input type file Jan 25, 2016
@weierophinney weierophinney added this to the 2.5.2 milestone Feb 16, 2016
@weierophinney weierophinney self-assigned this Feb 16, 2016
@weierophinney weierophinney merged commit 47e9599 into zendframework:master Feb 16, 2016
weierophinney added a commit that referenced this pull request Feb 16, 2016
[BUG] This fix allows the upload of same filenames in input type file
weierophinney added a commit that referenced this pull request Feb 16, 2016
weierophinney added a commit that referenced this pull request Feb 16, 2016
weierophinney added a commit that referenced this pull request Feb 16, 2016
@wolxXx
Copy link

wolxXx commented Mar 3, 2017

sadly, this breakes the possibility to save the original file name.
in my case, a single file is uploaded with the example name "foobar.jpg" and will be renamed to "[php_3532 as php tmp file name]_foobar.jpg"... so now i must parse the tmp file out of the new file name..
that's weird..
it would be nice if the rename in https://github.com/zendframework/zend-file/blob/master/src/Transfer/Adapter/Http.php#L454 would be optionally.

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

Successfully merging this pull request may close these issues.

3 participants