Código HTML:
Este codigo lo encontre de una web q' utiliza Ajax UploadVer original
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <style type="text/css"> .del {margin-left:20px} </style> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script type="text/javascript"> $(function(){ //counting upload time var count = $('#files').children('li').size(); new AjaxUpload('upload_button', { action: 'upload.php', name: 'userfile', autoSubmit: true, responseType: 'json', onChange: function(file, extension){}, onSubmit: function(file, extension) { //set file permission if (! (extension && /^(jpg|png|jpeg|gif)$/.test(extension))){ alert('Error: Chỉ chấp nhận file hình ảnh.'); return false; } // increment count count ++; // count submission if(count > 12){ alert('vượt quá số lượng hình ảnh cho phép'); return false; } // showing loader var li = $('#files').children('li').size(); if(count > li ){ $('#loader').show(); } }, onComplete: function(file, response) { // add delete link if(response.status == 'success') { $('#files').append(list_item); } else{ count--; alert(response.errors +' ' + file); } // remove the loader var li = $('#files').children('li').size(); if(count == li){ $('#loader').hide(); } // if clicked, remove image completely $('.del').click(function(e){ e.preventDefault(); $.post('delet.php', {ori: response.img_name , thumb: response.thumb_name }, function(){}, 'json'); $(this).parent().remove(); count --; }); } }); }); </script> </head> <body> <img id="loader" src="/img/loader.gif" style="display:none" /> </body> </html>
Mi codigo de Upload es:
Código PHP:
Me sale un error: PHP Parse error: syntax error, unexpected T_VARIABLE in /home/vkmanga/public_html/admin/upload.php on line 3Ver original
<?PHP $uploaddir = '/home/miweb/public_html/admin/' echo "success"; } else { // WARNING! DO NOT USE "FALSE" STRING AS A RESPONSE! // Otherwise onSubmit event will not be fired echo "error"; } ?>
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
No se q' me estoy ekivocando para subir imagenes mediante AJAX y PHP, me pueden guiar q' debo q' cambio debo hacer.
Salu2!!