Ahoj,
mám multiple upload přes jQuery AJAX a PHP. Jednu dobu mi to fungovalo, pak sjem tam ale něco upravoval a háže mi to chybu s neidentifikovaným indexem..nevím proč.
Tady je index.php:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<link rel="stylesheet" type="text/css" href="css/style.css" />
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/jquery_ui.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#upload-form").submit(function() {
var src = $(this).serializeArray();
$.ajax({
type: "POST",
url: "upload.php",
data: src,
success: function(response) {
$('#uploaded-files').append(response);
}
});
return false;
});
});
</script>
</head>
<body>
<form enctype="multipart/form-data" id="upload-form">
<input type="file" name="pics[]" multiple="" />
<input type="submit" name="send" value="nahrát" />
</form>
<ul id="uploaded-files">
</ul>
</body>
A zde upload.php:
<?php
$names='';
foreach($_FILES['pics']['error'] as $key=>$error) {
if(!$error) {
$tmpName=$_FILES['pics']['tmp_name'][$key];
$name=$_FILES['pics']['name'][$key];
move_uploaded_file($tmpName,'data/'.$name);
$names.='<li>'.$name.'</li>';
}
}
echo $names;
?>
Chyba je:
Notice: Undefined index: pics in /Library/WebServer/Documents/multiupload/upload.php on line 3 Warning: Invalid argument supplied for foreach() in /Library/WebServer/Documents/multiupload/upload.php on line 3
Kdyby jste tam někdo tu chybu našel a řekl mi kde je, byl bych moc vděčný :)