j 'ai un code pour upload les imags en jquery à savoir:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
var uploader = new plupload.Uploader({
	runtimes : 'html5,flash',
	browse_button : 'browse',
	drop_element:'droparea',
	container: 'plupload',
	url : 'upload.php',
	flash_swf_url : 'js/plupload/plupload.flash.swf',
	multipart: true,
	urlstream_upload: true,
	multipart_params:{directory:'test'},
});
 
uploader.bind('UploadProgress',function(up,file){
	console.log(file);
		$('#'+file.id).find('.progress').css('width',file.percent+'%');
		})
 
uploader.init();
 
uploader.bind('FilesAdded',function(up,files)
    {
		var filelist = $('#filelist');
 
		for(var i in files)
		    {
				var file = files[i];
filelist.prepend('<div id ="'+file.id+'" class ="file">'+file.name+' ('+plupload.formatSize(file.size)+')'+'<div class="progressbar"><div class="progress"></div></div></div>');
			}
			$('#droparea').removeClass('hover')
			uploader.start();
			uploader.refresh();
	});
 
	uploader.bind('Error',function(up, err){
		alert(err.message);
		$('#droparea').removeClass('hover')
		uploader.refresh();
 
		});
 
	uploader.bind('FileUploaded',function(up, file, response){
		 data = $.parseJSON(response.response);
		 var ror = $('#erreur');
		 $('.erreur').remove();
		if(data.error)
		{
			ror.prepend('<div class="erreur">'+ data.message+'</div>');
 
			$('#'+file.id).remove();
			}
			else {
				$('#'+file.id).find('.progressbar').fadeOut();
				}
		});
 
	jQuery(function($){
 
		$('#droparea').bind({
			dragover : function(e){
				$(this).addClass('hover');
		},
		dragleave : function(e){
			$(this).removeClass('hover');
		}
	});
		})
et coté php voici le code
Code php : Sélectionner tout - Visualiser dans une fenêtre à part
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
71
72
73
<?php
 
include 'functions.php';
 session_start();
 
$upload_dir = "upload_pic"; 
$upload_path = $upload_dir."/";	
$upload_dir_thumbs = "upload_pic/thumbs" ;				// The directory for the images to be saved in
$upload_path_thumbs = $upload_dir_thumbs."/";	
$max_file = "3"; 							// Maximum file size in MB
$max_width = "600";								// Max width allowed for the large image
$thumb_width= "100";						// Width of thumbnail image
$thumb_height = "100";						// Height of thumbnail image
 
//Create the upload directory with the right permissions if it doesn't exist
if(!is_dir($upload_dir)){
	mkdir($upload_dir, 0777);
	chmod($upload_dir, 0777);
}
if(isset($_SESSION['image'])){ 
$large_image_location = $upload_path.$_SESSION['image'];
$thumb_image_location = $upload_path_thumbs.$_SESSION['image'];
 
if (file_exists($large_image_location)){
	if(file_exists($thumb_image_location)){
		$thumb_photo_exists = "<img src=\"".$thumb_image_location."\" alt=\"Thumbnail Image\"/>";
	}else{
		$thumb_photo_exists = "";
	}
   	$large_photo_exists = "<img src=\"".$large_image_location."\" alt=\"Large Image\"/>";
} else {
   	$large_photo_exists = "";
	$thumb_photo_exists = "";
}
}
 
	//Get the file information
	$userfile_name = $_FILES['file']['name'];
	$userfile_tmp = $_FILES['file']['tmp_name'];
	$userfile_size = $_FILES['file']['size'];
	$userfile_type = $_FILES['file']['type'];
	$filename = basename($_FILES['file']['name']);
    $targetfile =  $upload_path.$userfile_name;
 
	//Only process if the file is a JPG, PNG or GIF and below the allowed limit
	if(!empty($_FILES["file"])) {
 
 
		if (isset($_FILES['file']['name'])){
			//this file could now has an unknown file extension (we hope it's one of the ones set above!)
		//put the file ext in the session so we know what file to look for once its uploaded
			$_SESSION['image']=$userfile_name;
 
			move_uploaded_file($userfile_tmp, $targetfile);
			chmod($large_image_location, 0777);
 
			$width = getWidth($targetfile );
			$height = getHeight($targetfile );
 
			//Scale the image if it is greater than the width set above
			if ($width > $max_width){
				$scale = $max_width/$width;
				$uploaded = resizeImage($targetfile ,$width,$height,$scale);
			}else{
				$scale = 1;
				$uploaded = resizeImage($targetfile ,$width,$height,$scale);
			}
	        die('{"error":false, "message": "ok"}');
		}
 
	}
 
?>
et j 'aimerai que la page se rafraichit lorsque ajax recoit la reponse "ok" mais je n'y parviens pas