Home  |  Linux  | Mysql  | PHP  | XML
From:Bilal Ahmad Date:Wed Feb 10 11:16:43 2010
Subject:Upload_File
Hi I am trying to make a form to provide option to user to upload a file on
a server.Here is the code for my upload.php. It checks all the conditions
etc.. . This code works fine on localhost , and file is uploaded
successfully. But when I use this script online on my server, it gives me
error. couldn't figure out what is error.
What I think is error in move_upload_file, but it isn't returning any error.
File permissions on upload folder are 755.



if((!empty($_FILES['uploaded_file'])) && ($_FILES['uploaded_file']['error']
== 0)){

$ok = 0;
$filename = basename($_FILES['uploaded_file']['name']);

$ext = substr($filename, strrpos($filename, '.') + 1);

if (($ext == "jpg" || "gif" || "png") && ($_FILES["uploaded_file"]["type"]
== "image/jpeg" || "image/gif" || "image/png") &&
($_FILES["uploaded_file"]["size"] < 2097152) ){

$newname = 'upload/'.$filename;

if (!file_exists($newname)) {

if
((move_uploaded_file($_FILES['uploaded_file']['tmp_name'],$newname))) {
$ok = "1";
echo "It's done! The file has been saved as: ".$newname;
} else {
echo "Error: A problem occurred during file upload!"; //This one
executes when ever i try to upload file on server.
}
} else {
echo "Error: File ".$_FILES["uploaded_file"]["name"]." already
exists";
}
} else {
echo "Error: Only .jpg images under 2MB are accepted for upload";
}
} else {
echo "Error: No file uploaded";
}

Thanks
Bilal Farooq Ahmad

Navigate in group php.db at sever news.php.net
Previous Next


Your recent visits
Re: [PHP-DB] finding out if a user left our website ?
Re: [PHP-DB] finding out if a user left our website ?
RE: [PHP-DB] Database management



  
© No Copyright
You are free to use Anything, but please consult your advocate before doing so as this website
also list content from other sources which may be copyrighted.
Site Maintained by Zareef Ahmed
Powered By PHP Consultants