html - Remove empty space from file uploads? -


so have html file upload form backend below:

if(isset($_post['two'])){     $target_dir = "pageimg/";     $target_file = $target_dir . basename($_files["image"]["name"]);     $uploadok = 0;     $imagefiletype = pathinfo($target_file,pathinfo_extension);  // check if image file actual image or fake image      $check = getimagesize($_files["image"]["tmp_name"]);     if($check !== false) {         $uploadok = 0;     } else {         $uploadok = 1;     }  // check if file exists  if (file_exists($target_file)) {     $uploadok = 2; } // check file size  if ($_files["image"]["size"] > 500000) {     $uploadok = 3; } // allow file formats  if($imagefiletype != "jpg" && $imagefiletype != "png" && $imagefiletype != "jpeg" && $imagefiletype != "gif" ) {     echo "sorry, jpg, jpeg, png & gif files allowed.";     $uploadok = 4; } // check if $uploadok set 0 error  if ($uploadok == 5) {     echo "sorry, file not uploaded.";  // if ok, try upload file  } else {     if (move_uploaded_file($_files["image"]["tmp_name"], $target_file)) {         echo "the file ". basename( $_files["image"]["name"]). " has been uploaded.";     } else {         echo "sorry, there error uploading file.";     } } } 

this works , uploads files should, however, if upload file such fb logo.png upload such space. looking edit script close spaces or rename images? have looked around , have found no luck on how implement script current script? seems bit "here code" work out , i've had no luck. did try this...

str_replace(" ", "_", $_files['image']['name']); 

but not sure have added correctly? image failed upload on test.

also, how recall image name? use :

$_files['name']; 

just recall image name?


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

c# - Retrieve google contact -

javascript - How to insert selected radio button value into table cell -