I'm trying to make a multi file uploader.
I'm using "Multiple File Upload Magic With Unobtrusive Javascript"
Dosyaların hiçbiri yükleyin. Bir diziye dosyaları koyarak çünkü ben bu olduğuna eminim ve benim php (ben nasıl bilmiyorum) dizi işlemek için ayarlanmış gerekmez. Ben ne yapıyorum yanlış herhangi bir yardım?
Şimdiden teşekkürler! :)
JQUERY KOD
$(document).ready(function(){
var fileMax = 12;
$('#element_input').after('<div id="files_list"></div>');
$("input.upload").change(function(){
doIt(this, fileMax);
});
});
function doIt(obj, fm) {
if($('input.upload').size() > fm) {alert('Max files is '+fm); obj.value='';return true;}
$(obj).hide();
$(obj).parent().prepend('<input type="file" class="upload" name="fileX[]" />').find("input").change(function() {doIt(this, fm)});
var v = obj.value;
if(v != '') {
$("div#files_list").append('<div>'+v+'<input type="button" class="remove" value="" /></div>')
.find("input").click(function(){
$(this).parent().remove();
$(obj).remove();
return true;
});
}
};
HTML KOD
<form action="myPhpCodeIsBelow.php" method="post" enctype="multipart/form-data" name="asdf" id="asdf">
<div id="mUpload">
<input type="file" id="element_input" class="upload" name="fileX[]" />
<input type="submit" value="Upload" />
</div>
</form>
PHP KODU
$target = "upload/";
$target = $target . $_FILES['fileX']['name'];
$ok=1;
if(move_uploaded_file($_FILES['fileX']['tmp_name'], $target)) {
echo "The file " . $_FILES['fileX']['name'] . " has been uploaded";
}
else {
echo "There was a problem uploading" . $_FILES['fileX']['name'] . ". Sorry";
}