我正在尝试上传图片,但它总是向我显示错误。我想我已经完成了上传图片所需的一切。任何帮助将不胜感激。
<form action="../Code Files/User.php" method="post" enctype="multipart/form-data">
<div id="photo_settings2" style="margin-left:74px;">
<img id="Picture" src="../../img/User No-Frame.png"/>
</div>
<br><br><br><br>
<div id='Upload_Panel' style="margin-left: 32px;">
<input name='file' type='file' id='file_browse' onchange="readURL(this,'Picture')" style="cursor: pointer;"/>
</div>
<div id="delete" style="margin-top: -40px; margin-left: 198px; cursor: pointer">
<img src="../../img/Delete_Panel.png">
</div>
<div style="margin-left:144px; margin-top:-15px"></div>
<br><br>
</div>
</div>
</form>
$UploadDirectory = '/www/';
if(move_uploaded_file($_FILES['file']['file'], $UploadDirectory))
{
die('Success! File Uploaded.');
}
else
{
die('error uploading File!');
}
答案 0 :(得分:0)
这应该有效:
if(move_uploaded_file($_FILES['file']['tmp_name'], basename($_FILES['file']['name'])))
{
die('Success! File Uploaded.');
}
else
{
die('error uploading File!');
}
编辑:我已更改目标参数 - 现在上传的文件将出现在您的php文件旁边。记住目标文件夹权限。
答案 1 :(得分:0)
$UploadDirectory = '/wamp/www/img/Users/Users/'.basename($_FILES['file']['name']);
if(move_uploaded_file($_FILES['file']['tmp_name'], $UploadDirectory))
{
die('Success! File Uploaded.');
}
else
{
die('error uploading File!');
}