我正在创建一个插件,允许管理员手动输入用户。其中一个选项是包含图像。我无法将图像从计算机传输到目录中。这是我的
表单如下所示
<form action="" method="post" enctype="multipart/form-data" >
First name: <input type="text" name="firstname"><br>
Last name: <input type="text" name="lastname"><br>
Picture:<input type="file" name="picture"><br>
<input type="submit" name="adminsubmit" value="Submit"/>
</form>
单击提交按钮后,我会在顶部调用此
if(isset($_POST[\'adminsubmit\']))
{
include (\'adminInsert.php\');
}
我的管理员插入。php文件如下所示
$target_path="http://www....";
$target_path = $target_path . basename( $_FILES[\'picture\'][\'name\']);
if(move_uploaded_file($_FILES[\'picture\'][\'temp_name\'], $target_path)) {
echo "The file ". basename( $_FILES[\'picture\'][\'name\']).
" has been uploaded";
} else{
echo "There was an error uploading". ( $_FILES[\'picture\'][\'name\']).", please try again!";
}
这是我打印$\\u文件时得到的结果
Array ( [picture] => Array ( [name] => morningGloryForSite.png [type] => image/png [tmp_name] => /tmp/php3j4sls [error] => 0 [size] => 119880 ) )
我只是不断返回IF语句的ELSE部分。我无法将文件传输到所需的目录。有人能看看这个并提出一些答案吗?
提前感谢您!