文件未上传到我的服务器中,我正在使用move_uploaded_file 功能,我得到输出,因为您的文件已成功上传。但 文件不在该位置。
image.html
composer
imageupload.php
<script>
$(document).ready(function(){
$(document).on('change', '#profile_photo', function(){
var file_data = $('#profile_photo').prop('files')[0]['name'];
var email_id=document.getElementById('email_id').value;
var filename=document.getElementById('profile_photo').files[0]['name'];
form_data.append('file', document.getElementById('profile_photo').files[0]);
$.ajax({
url:"https://imageupload.php",
method:"POST",
data:({'file':filename,'email_id':email_id }),
beforeSend:function(){
$('#uploaded_image').html("<label class='text-success'>file Uploading...</label>");
},
success:function(data) {
$('#uploaded_image').html(data);
}
});
});
});
</script>
答案 0 :(得分:-1)
imageupload.php 请尝试下面的代码,并确保将上载文件夹权限设置为777。
<?php
$filename=$_POST['file']['name'];
$tmppath = $_FILES['file']['tmp_name'];
$email_id=$_POST['email_id'].substr($filename, -5);
if(file_exists("upload/" . $email_id)){
echo $filename . " is already exists.";
} else{
move_uploaded_file($tmppath, "upload/".$email_id);
echo $email_id."Your file was uploaded successfully.";
}
?>