|
Posted by igrosny@gmail.com on 11/15/07 12:14
On 15 nov, 08:46, "skulkrinb...@googlemail.com"
<skulkrinb...@googlemail.com> wrote:
> 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.
Hi, try this
if (isset($_FILES['imagefile']['name']))
hope it helps
Navigation:
[Reply to this message]
|