Hola a todos tiempo q' no venia pero ahora tengo un inconveniente estoy empezando a utilizar AJAX y estoy utilizando este codigo
Código HTML:
Ver 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"> .del {margin-left:20px}
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> <script type="text/javascript" src="js/ajaxupload.js"></script> <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') {
var list_item = '
<li><img src="admin/'+ response.thumb_name +'" />';
list_item += '
<a href="#" class="del">remove
</a></li>';
$('#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 --;
});
}
});
});
<a href="#" id="upload_button" style="cursor:pointer">Upload
</a> <img id="loader" src="/img/loader.gif" style="display:none" />
Este codigo lo encontre de una web q' utiliza Ajax Upload
Mi codigo de Upload es:
Código PHP:
Ver original<?PHP
$uploaddir = '/home/miweb/public_html/admin/'
$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
echo "success";
} else {
// WARNING! DO NOT USE "FALSE" STRING AS A RESPONSE!
// Otherwise onSubmit event will not be fired
echo "error";
}
?>
Me sale un error: PHP Parse error: syntax error, unexpected T_VARIABLE in /home/vkmanga/public_html/admin/upload.php on line 3
$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!!