You are here: Re: Help with Image/$_FILES Handling please « PHP Programming Language « IT news, forums, messages
Re: Help with Image/$_FILES Handling please

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация