0
formData를 사용하여 이메일()에 첨부 : 나는 제목 아래에서 here의 코드를 사용하고
submit success but upload not work at combine form은 파일을 업로드하고 가능한 중복
는 "만 제출 파일". 코드는 정말 간단하고 작지만 console.log에 "file", 위치가 없으면 webkitrelativepath는 ""입니다. 제출시 파일 이름, 크기 등을 볼 수 있습니다. 나는 그것을 내 feedback.php 파일에 게시하고 거기에서 전자 메일에 첨부해야하지만 formData에서 파일을 가져 와서 내 업로드 폴더를 업로드하는 방법을 모르므로 전자 메일을 보낼 수 있습니다. -mail it ...
감사합니다.
편집 :
내가 지금 사용하고 무엇 코드 :
var fileInput = document.getElementById('file-upload-field');
var file = fileInput.files[0];
var formData = new FormData();
formData.append('file', file);
console.log(file);
$.ajax({
url: baseUrl + "feedback.php",
data: file,
cache: false,
contentType: false,
processData: false,
type: 'POST',
success: function(file){
alert(file);
}
});
내 feedback.php에
foreach($_FILES as $file){
$target_path = "uploads/";
$target_path = $target_path .basename($file['name']);
if(move_uploaded_file($file['tmp_name'], $target_path)) {
echo "the file ".basename($file['name'])." has been uploaded";
}
else {
echo "there was an error";
}
$mail->AddAttachment($target_path);
}
이 업로드되지 않거나 어디서나 파일을 첨부하십시오 ...
: HTTP : //blog.new-bamboo .co.uk/2012/01/10/우스꽝스럽게 단순한 아약스 업로드와 함께 formdata? –
알았어, 내 의견을 바꿨다. 초. File API를 명시 적으로 사용하고 있다는 사실을 알지 못했습니다. – Charles
이렇게 업로드 된 파일은'$ _FILES' *에 나타나지 않습니다. 정의 된 경우'stdin'을 읽거나'$ HTTP_RAW_POST_DATA'를 볼 필요가 있습니다. 즉, MIME 유형이나 원래 사용자 파일 이름도 얻지 못합니다. *이 작업을 위해 제 3 자 업로드 위젯을 사용하라고 촉구합니다. – Charles