/    Sign up×
Community /Pin to ProfileBookmark

If I create an input type=files in the html form
Then in the target php script use the $_FILES array to get the info
All works well – uploads work fine.

But . . . if the file name contains a single quote mark, the name from $_FILES is not correct. The resulting $_FILES[‘file’][‘name’] gives the name from the next character after the single quote to the end (like a reverse truncation). Only the single quote casues this (that I have found). The upload still works, but with a wierd file name result.


———————————————————–

Example test code to demonstrate the problem:

html upload page (test.htm):

[code]<form action=”test.php” method=”post” enctype=”multipart/form-data”>
File: <input type=file name=”file” size=30><br>
<input type=submit name=”submit” value=”Upload File”></form>[/code]

php processing page (test.php):

[code=php]<?php
print_r($_FILES);
?>[/code]

Then try and use any file name with a single quote in it.


————————————————————-

Running PHP Version 4.3.10 with the error
Works fine when using PHP Version 4.3.4
Enhancement or bug?

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@Beach_BumauthorJan 12.2005 — Found it - this is a known bug in php 4.3.10

http://bugs.php.net/bug.php?id=31398
Copy linkTweet thisAlerts:
@scragarJan 12.2005 — try replacing it with something else then changing it back when needed.
×

Success!

Help @Beach_Bum spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...