file upload - Simple FileUpload with php doesn't work -


i have code:

$filename=$_files["filetoupload"]["name"]; $extension=explode(".", $filename); $newfilename=$rezeptid .".".$extension;         if ($_files["filetoupload"]["error"] > 0)         {         echo "return code: " . $_files["filetoupload"]["error"] . "<br />";         }       else         {         echo "upload: " . $_files["filetoupload"]["name"] . "<br />";         echo "type: " . $_files["filetoupload"]["type"] . "<br />";         echo "size: " . ($_files["filetoupload"]["size"] / 1024) . " kb<br />";         echo "temp file: " . $_files["filetoupload"]["tmp_name"] . "<br />";          if (file_exists("/images/rezepte/" . $_files["filetoupload"]["name"]))           {           echo $_files["filetoupload"]["name"] . " exists. ";           }         else           {           move_uploaded_file($filename,           "/images/rezepte/" . $newfilename);           echo "stored in: " . "/images/rezepte/" .$newfilename;           }         } 

the variable $rezeptinfo number , correct, if wonder.

when submit form, info file:

"upload: type: size: 0 kb temp file: stored in: /images/rezepte/10."

why extension of file , basic information mssing. 10 value of $rezeptid. doing wrong?

first, way of getting extension returns array , cant concatenated string, need specify index of array extension 1 :

$newfilename=$rezeptid .".".$extension[1]; 

or

$newfilename=$rezeptid .".".end($extension); 

or

$extension = pathinfo($filename, pathinfo_extension); 

also, u should move uploaded file temp_file path

move_uploaded_file($_files["filetoupload"]["tmp_name"],"images/" .$newfilename); 

you should ensure enctype="multipart/form-data" included in html form property


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -