0

我有一个图片上传脚本在上传表单页面中有一个输入字段,如下所示:

处理图片上传的 php 脚本的一部分是:

$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

我的问题是文件没有上传。请你帮助我好吗

4

1 回答 1

1

执行一个var_dump$_FILES如果它是空的,你可能没有正确提交你的表单。

包含文件的表单必须包含enctype="multipart/form-data"

祝你好运!

于 2011-11-03T14:14:15.817 回答