Есть запрос:
$( "#upload" ).click( function()
{
$.ajax
({
method: "POST",
url: "server.php",
data: { func: "UploadImages" },
success: function( data )
{
alert(data);
}
});
});
Есть html:
<script src = "js/jquery-2.1.4.min.js" type = "text/javascript"></script>
<input type="file" name="files[]"/>
<button id='upload'>загрузить</button>
есть PHP:
<?php
if ( $_POST["func"] == "UploadImages" )
{
if ($_SERVER['REQUEST_METHOD'] === 'POST')
{
$error = $_FILES['files']['error'];
$name = $_FILES['files']['name'];
switch($error)
{
case UPLOAD_ERR_OK: echo($name); break;
case UPLOAD_ERR_INI_SIZE: echo("The uploaded file exceeds the upload_max_filesize directive in php.ini."); break;
case UPLOAD_ERR_PARTIAL: echo("he uploaded file was only partially uploaded."); break;
case UPLOAD_ERR_NO_FILE: echo("No file was uploaded."); break;
case UPLOAD_ERR_NO_TMP_DIR: echo("Missing a temporary folder. Introduced in PHP 4.3.10 and PHP 5.0.3."); break;
case UPLOAD_ERR_CANT_WRITE: echo("Failed to write file to disk. Introduced in PHP 5.1.0."); break;
case UPLOAD_ERR_EXTENSION: echo("File upload stopped by extension. Introduced in PHP 5.2.0."); break;
}
}
}
?>
Почему в переменную name ничего не приходит?