1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
| <?php
$repdossier = $_GET['repdossier'];
?>
<!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" dir="ltr">
<head profile="http://gmpg.org/xfn/11">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>AJAX File Upload - Web Developer Plus Demos</title>
<script type="text/javascript" src="js/jquery-1.3.2.js" ></script>
<script type="text/javascript" src="js/ajaxupload.3.5.js" ></script>
<link rel="stylesheet" type="text/css" href="./styles.css" />
<script type="text/javascript" >
$(function(){
var btnUpload=$('#upload');
var status=$('#status');
new AjaxUpload(btnUpload, {
<?php
echo "action: 'upload-file.php?repdossier=".$repdossier."',";
?>
name: 'uploadfile',
onSubmit: function(file, ext){
if (! (ext && /^(jpg|png|jpeg|gif)$/.test(ext))){
// extension is not allowed
status.text('Les extentions possible sont JPG, PNG ou GIF');
return false;
}
status.html('Envoi en cours <img src="images/loadingup.gif?<?php echo md5(time()); ?>" border="0" height="6" width="19">');
},
onComplete: function(file, response){
//On completion clear the status
status.text('');
//Add uploaded file to list
if(response==="success"){
$('<li></li>').appendTo('#files').html('<img src="miniature.php?pic=upload/<?php echo $repdossier; ?>/'+file+'&w_max=70&h_max=60" height="60" width="70" alt="" /><br />').addClass('success');
}
if(response==="error1"){
alert("Vous avez déjà 5 photos pour votre annonce !\nLe maximum de photos autorisées est de 5 !")
}
if(response==="error2"){
alert("La photo selectionnée existe déjà\nRe-selectionnez une autre photo !")
}
}
});
});
</script>
</head>
<body>
<div id="mainbody" >
<div id="upload" ><span>Ajouter des photos<span></div><span id="status" ></span>
<ul id="files" ></ul>
</div>
</body>
</html>
</code> |
Partager