1
我卡在這裏。我一直在嘗試上傳一些照片,同時將相冊的ID(表單中隱藏的值)傳遞給處理上傳的相同的php腳本。但我不知道如何通過專輯ID單獨這是代碼。傳遞數據到一個php腳本與AJAX
的js
input.addEventListener("change", function (evt) {
document.getElementById("response").innerHTML = "<img src='../assets/admin/images/loading.gif' />"
var i = 0, len = this.files.length, img, reader, file;
for (; i < len; i++) {
file = this.files[i];
if (!!file.type.match(/image.*/)) {
if (window.FileReader) {
reader = new FileReader();
reader.onloadend = function (e) {
showUploadedItem(e.target.result, file.fileName);
};
reader.readAsDataURL(file);
}
if (formdata) {
formdata.append("images[]", file);
}
}
}
if (formdata) {
$.ajax({
url: "../assets/admin/ajaxupload/upload.php",
type: "POST",
data: formdata,
processData: false,
contentType: false,
success: function (res) {
document.getElementById("response").innerHTML = res;
}
});
}
PHP
//how do i retrieve the given album id value that was passed.
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/pics/" .$_FILES['images']['name'][$key]);
}
}
echo "<p>Successfully Uploaded Images</p>";
請我需要一個答覆儘快感謝。
*請我需要一個答覆儘快感謝。 *這不是它如何工作的朋友。 –
並且這個其他的「相冊ID」是否坐在變量中? – 2012-05-10 09:50:36
是的,它在php代碼中。 –