Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

File upload handling...

Status
Not open for further replies.

kehers

Programmer
Aug 31, 2005
56
A2
I'm tring to run a file upload script that goes this way:
Code:
if($_POST['ad']){
print_r($_FILES);//just doing a little debugging trick here
if(is_uploaded_file($_FILE['ad']['tmp_name'])){
if($_FILES['ad']['type'] == 'image/gif' || $_FILES['ad']['type'] == 'application/x-shockwave-flash'){
//trying to use this: ...
//'application/x-shockwave-flash' to allow flash as well...
//hope correct
if(move_uploaded_file($_FILES['ad']['tmp_name'], 'var/www/ng/ngbot/ads/'.$_FILES['ad']['tmp_name'])){
echo "uploaded";
}
}else{
echo "Invalid file type!<p>";
}
}else{
echo "File upload error!<p>".$_FILES['ad']['error'];
}
}
I got the message File upload error which means (from my script) this: if(is_uploaded_file($_FILE['ad']['tmp_name'])){
...
}

was omitted.
what could be wrong?
 
Its minor changes but you definatley needed the leading / on your target directory for file uploads (var/
Code:
<?
if($_FILES['ad']){
        if($_FILES['ad']['type'] == 'image/gif' || $_FILES['ad']['type'] == 'application/x-shockwave-flash'){
//trying to use this: ...
//'application/x-shockwave-flash' to allow flash as well...
//hope correct
                if(move_uploaded_file($_FILES['ad']['tmp_name'], '/var/www/ng/ngbot/ads/'.$_FILES['ad']['name'])){
                        echo "uploaded<br>";
                }
        }else{
                echo "Invalid file type!<p>";
        }
}else{
echo "File upload error!<p>".$_FILES['ad']['error'];
}
?>

______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top