php使用Jquery Ajax未将图像上载到文件夹
我的HTML如下php使用Jquery Ajax未将图像上载到文件夹,php,jquery,ajax,Php,Jquery,Ajax,我的HTML如下 <form id="df" enctype="multipart/form-data"> <input type="email" name="email"> <input type="file" name="image"> <button type="submit" id="submit">Submit</button> </form> 我的PHP脚本 <?php $file = $_POST["e
<form id="df" enctype="multipart/form-data">
<input type="email" name="email">
<input type="file" name="image">
<button type="submit" id="submit">Submit</button>
</form>
我的PHP脚本
<?php
$file = $_POST["email"];
$path = "uploads/$file";
mkdir($path);
$t = $path.'/'.$_FILES['image']['name'];
$s = $_FILES['image']['tmp_name'];
echo "File name : " .$_FILES['image']['name']. "</br>";
echo "File type : " .$_FILES['image']['type']. "</br>";
echo "File size : " .$_FILES['image']['size']. "</br>";
move_uploaded_file($s,$t);
if (is_uploaded_file($_FILES['image']['tmp_name'])) {
echo "File ". $_FILES['image']['name'] ." uploaded successfully.\n";
}
else {
echo "File Not uploaded";
}
echo '<img src="'.$t.'" alt="No image selected" class="img-responsive">';
?>
正在uploads文件夹中创建名为email id的子文件夹,但未将图像上载到该文件夹。哪里出错了?您需要在表单标记中添加
enctype=“multipart/form data”>
。
是的
<form id="df" enctype="multipart/form-data">
可能文件不是图像,可能与权限有关。试试chmod?我错了,我以前没放过。是的,我有一种。
File name : IMG_20150526_194112.jpg
File type :
File size : 0
File Not uploaded
<form id="df" enctype="multipart/form-data">