【发布时间】:2014-10-19 18:34:06
【问题描述】:
我正在尝试通过表单和 php 文件上传文件。我在整个网站上多次使用相同的方法,没有任何问题,但是这次我无法让它工作。在我的表格上,我有这个....
<span class="purple"><strong>Upload Your Image</strong></span>
<input name="userfile" type="file" id="userfile" class="textbox">
<br /><br />
<label>
<input name="submit" type="submit" class="createbutton" id="submit1" value="ADD TO BASKET">
</label>
在我的 php 文件中,我有这个...
//upload image first
$uploaddir = '../images/';
$uploadfile = $uploaddir. $_FILES['userfile']['name'];
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) {
$status = 1;//uploaded
$data["printfile"] = $_FILES['userfile']['name'];
} else {
$status = 0;//cant upload
echo "Upload Failed!\n";
$err = "";
}
每次它只是给我上传失败错误消息。有什么想法吗?
【问题讨论】:
-
你在
-
-
你能把你的整个表格贴出来吗?
-
如果你在 *nix 系统上,那么它 '../images/' 应该有 777 权限,如果一切都是正确的。除了这个!
标签: php forms file-upload upload