forms - Image upload failing in PHP -


so i'm trying set image upload form via php on localhost , after running code , connecting database okay, i'm getting error upload. since of other parts of form working after section section check, i'll add html upload input , relevant php script.

<input type="file" name="image" id="image-select" /> 

and portion of php has deal image upload , verification after upload:

$image = $_files ['image']['name']; $type = @getimagesize ($_files ['image']['tmp_name']);  //never assume image upload okay if ($_files['image']['error'] !== upload_err_ok) {     die("upload failed error code " . $_files['image']['error']); }  //where file placed $target_path = "uploads/";  // add original filename target path $path= $target_path . basename($image);  // check if image invalid before continuing  if($type === false || !($type[2] === imagetype_tiff || $type[2] === imagetype_jpeg || $type[2] === imagetype_png)) {     echo '<script "text/javascript">alert("this not valid image file!")</script>';     die("this not valid image file!");  } else {         move_uploaded_file($_files['image']['tmp_name'], $path);  } 

so error appears once code hits upload process. attempting upload small png file relevant code added in respective orders when appear in script.

can please put error here. if error means after submit page file not being upload. please check form enctype. see below example

<form action="" method="post" enctype="multipart/form-data"> <input type="file" name="image" id="image-select" /> <input type="submit" value="submit"> </form> 

Comments

Popular posts from this blog

php - get table cell data from and place a copy in another table -

javascript - Mootools wait with Fx.Morph start -

php - Navigate throught databse rows -