【发布时间】:2015-10-30 17:46:18
【问题描述】:
我正在尝试学习通过 PHP 上传图片。 我试图上传图片,不包括格式和大小的验证码,突然发生了这个错误。我尝试更改标签的名称属性。但这并没有解决我的问题。
我的代码是:
<?php
if($_SERVER['REQUEST_METHOD'] == "POST") {
$target_dir = "../images/images_channel/";
$target_file = $target_dir . basename($_FILES['image']['name']);
$imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
$new_image_name = $target_dir . "abc" . "." . pathinfo($target_file,PATHINFO_EXTENSION);
if(move_uploaded_file($_FILES["image"]["tmp_name"], $new_image_name)) {
echo "success";
}
else {
echo "fail";
}
}
?>
<form action="" method="POST">
<input type="file" name="image" id="image" />
<input type="submit" value="Submit" />
</form>
两个错误是:
注意:未定义索引:第 4 行 E:\wamp\www\new22\alfasahah\admin\check.php 中的图像
注意:未定义索引:第 7 行 E:\wamp\www\new22\alfasahah\admin\check.php 中的图像
【问题讨论】:
标签: php image file wamp image-uploading