这是我用于使用AJAX将我的图像传递给php的示例jQuery编码。
HTML输入
<input id="forkliftImagePath" name="image" type="file" />
admin_forklift_detail.php
$.ajax({
type: "POST",
url: "../Client/php/add_forklift_detail_process.php",
data: str,
cache: false,
contentType: false,
processData: false,
async: false,
success: function(msg) {
alert(msg);
}
})
这是另一个执行从AJAX传递的代码的php文件。在此文件中将获取图像名称并传回“admin_forklift_detail.php”以进行警报。
add_forklift_detail_process.php
<?php
$name = $_FILES['image']['name'];
echo $name;
?>