首先,我开始说我是Ajax和PHP的新手,所以即时通讯询问是否有人可以帮助我。
我正在制作一种方式,用户可以在图像的帧内上传图像,它工作正常,如果用户尝试将图像上传到PDF(使用DOMPDF),它不会自己上传图像
简而言之,它需要能够将图像上传到名为“上传”的文件
Jquery的(AJAX)
(form.save是一个名称在其中保存的表单标记)
log($(e.target).closest('form.save')[0],$(('FormData')[2]));
$.ajax({
url: 'images.php', // Url to which the request is send
type: 'POST', // Type of request to be send, called as method
data: $(e.target).closest('form.save'), // Data sent to server, a set of key/value pairs (i.e. form fields and values)
contentType: false, // The content type used when sending data to the server.
cache: false, // To unable request pages to be cached
processData:false, // To send DOMDocument or non processed data file it is set to false
success: function(data) // A function to be called if request succeeds
{
$('#loading').hide();
$('#message').html(data);
}
});
PHP
<?php
foreach($_FILES["images"]["error"] as $key => $error) {
if ($error == UPLOAD_ERR_OK) {
$name = $_FILES["images"]["name"][$key];
move_uploaded_file( $_FILES["images"]["tmp_name"][$key], "uploads/" . $_FILES['images']['name'][$key]);
}
}
echo "<h2>Successfully Uploaded Images</h2>";
?>
提前致谢!,
有什么问题吗?我很高兴听到他们。