Posted by skulkrinbait@googlemail.com on 11/15/07 11:46
I've a HTML form that allows a user to specify the location to upload
a file from:
<p><label for = 'file'>Upload Graphics : <input type='file'
name='imagefile' /></label></p>
I then want to check if the user entered something or not as this
isn't mandatory. Here's an excerpt of the relavent code:
if (isset($_POST['submit']))
{
if (isset($_FILES['imagefile']))
{
if ($_FILES['imagefile']['type'] == "image/gif")
{
copy ($_FILES['imagefile']['tmp_name'],
"images/".$_FILES['imagefile']['name'])
or die ("Could not copy");
The problem is the line: if (isset($_FILES['imagefile'])) isn't
doing what I expect it to do, it is always returning true and
executing the code in the if construct.
How can I solve this issue so that if the user isn't submitting
anything to be uploaded that it doesn't execute that code and vice
versa?
Thanks.
[Back to original message]
|