Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Checking input file is file exists + PHP

Checking input file is file exists + PHP
Thread Tools
Junior Member
Join Date: May 2003
Status: Offline
Reply With Quote
Jul 8, 2003, 02:39 PM
 
Hello all,

Is it possible to check an input type=file if a file is actually selected? I'd like to print an error is there is no file selected.

Please advise.

Jon31
www.jmarus.com - kicks by JM
     
Dedicated MacNNer
Join Date: Aug 2002
Status: Offline
Reply With Quote
Jul 9, 2003, 10:58 AM
 
yes...

[php]
if(is_uploaded_file($_FILES['file']['tmp_name'])==true) {
move_uploaded_file($_FILES['file']['tmp_name'],"/home/wherevere/".$_FILES['file']['name']) or die("failed to upload file");
} else {
echo("no file selected for upload!");
[/php]

where 'file' is the name of the file input form

if you haven't already looked at php.net, it is indespensible for any php development.

--will
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 03:47 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2