Upload image script is not working

531 views Asked by At

I have an image uploading script In upload form page there is an input field as shown below:

Part of the php script handling image upload is:

$path_parts = pathinfo($_FILES['product_image']['name']);
$imgext = $path_parts['extension'] ;

$imgextension = "." . $imgext ; //

// copying files to server
$target = "targetdomainpath/products/";
$target = $target . $_POST['product_name'].$imgextension;

//copying image
if(move_uploaded_file($_FILES['product_image']['tmp_name'], $target)) {
    //Tells you if its all ok
    echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded, and information has been modified inside the directory";
} else {
    //Gives and error if its not
    echo "Sorry, there was a problem uploading your file. or you didnt select photo from the computer";
}
// end image copying

My problem is file is not uploading. Could you please help me

1

There are 1 answers

1
Mikhail On BEST ANSWER

Perform a var_dump on $_FILES and if it's empty you're probably not submitting your form correctly.

Forms that include files must contain a enctype="multipart/form-data"

Good luck!