[RESOLU] Erreur lors d'une importation d'image

Eléphanteau du PHP | 41 Messages

29 août 2014, 13:45

Bonjour,

J'appel a votre aide car j'ai bidouille un script esapce membre, tout focntionne bien jusqu'ici a l'exception du module pour uploader des photos

suite a la selection d'une image et ensuite je valide, j'ai ceci comme message d'erreur :

Warning: move_uploaded_file(/membres/users/pics/3474Video-call-snapshot-8.png) [function.move-uploaded-file]: failed to open stream: No such file or directory in /home/sunnasea/www/membres/lib/functions/functions.php on line 908

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/phpRC2gE2' to '/membres/users/pics/3474Video-call-snapshot-8.png' in /home/***/www/membres/lib/functions/functions.php on line 908

J'ai pourtant verifier le chemin vers le dossier image, mais l'erreur persiste.

Ci-dessous la ligne 908 de mon fichier functions.php
	//move the temp file to the proper place
	if (move_uploaded_file($tmpfile, $save_path)) {
		$ext = pathinfo($save_path, PATHINFO_EXTENSION);
		$base = pathinfo($save_path, PATHINFO_FILENAME);
		$dir = pathinfo($save_path, PATHINFO_DIRNAME);
		$base_path = "$dir/$base";

		copy($save_path, "$base_path" . "_thumb" . "." . "$ext");
		createThumb("$base_path" . "_thumb" . "." . "$ext", $ext, 150);
		createThumb("$base_path" . "." . "$ext", $ext, 640);
et ci-dessous le code de mon fichier de verification :
<?PHP
checkLogin('2');
$id = 0;
if (isset($_GET['id'])){
	if (is_numeric($_GET['id'])){
		$id = strip_tags($_GET['id']);}
		}

$action = "";
if (isset($_GET['action'])){
	$action = strip_tags($_GET['action']);
		}	
			
	if ($action == 'delete'){
		$res = deleteImage($id);
			//if successful
			if ($res == 99){
				header("Location: /result.php?page=manage_photo&id=$id&message=Photo successfully deleted.");
				}
			if ($res == 1){
				header("Location: /result.php?page=manage_photo&id=$id&error=An error occured while trying to delete the photo.");
				}
	}
	
if (array_key_exists('addphoto', $_POST)) {
	$id = $_POST['id'];
	$imgpth = "/membres/users/pics/";
		$res = uploadUserImage($imgpth, $_FILES["picture"]["name"], $_FILES["picture"]["tmp_name"], $_POST["max"], $_POST['id']);
	
		if ($res == 99) {
			header("Location: /result.php?page=upload_photo&id=$pid&message=Photo uploaded successfully.");
		} elseif ($res == 1) {
			header("Location: /result.php?page=upload_photo&id=$pid&error=Image field empty.");
		} elseif ($res == 2) {
			header("Location: /result.php?page=upload_photo&id=$pid&error=Your image has exceeded the 300mb size limit required. Please select a smaller image file.");
		} elseif ($res == 3) {
			header("Location: /result.php?page=upload_photo&id=$pid&error=Unknown image extension. Images must be in jpg, jpeg, gif or png formats.");
		} elseif ($res == 4) {
			header("Location: /result.php?page=upload_photo&id=$pid&error=Unable to save image file. Please try again or contact site admin.");
		} elseif ($res == 5) {
			header("Location: /result.php?page=upload_photo&id=$pid&error=Unable to save image file. Please try again or contact site admin.");
		} else {
			header("Location: /result.php?page=upload_photo&id=$pid&error=There was an error uploading your image. Please try again.");
		}
	}
	
if (array_key_exists('updatephoto', $_POST)) {
	$id = $_POST['id'];
	$imgpth = "/membres/users/pics/";
		$res = updateUserImage($imgpth, $_FILES["picture"]["name"], $_FILES["picture"]["tmp_name"], $_POST["max"], $_POST['id']);
	
		if ($res == 99) {
			//header("Location: /result.php?page=update_photo&id=$pid&message=Photo updated successfully.");
			echo"Photo updated successfully";
		} elseif ($res == 1) {
			header("Location: /result.php?page=update_photo&id=$pid&error=Image field empty.");
		} elseif ($res == 2) {
			header("Location: /result.php?page=update_photo&id=$pid&error=Unknown image extension. Images must be in jpg, jpeg, gif or png formats.");
		} elseif ($res == 3) {
			header("Location: /result.php?page=update_photo&id=$pid&error=Your image has exceeded the 300mb size limit required. Please select a smaller image file.");
		} elseif ($res == 4) {
			header("Location: /result.php?page=update_photo&id=$pid&error=Unable to update image. Please try again, or contact the site administrator.");
		} else {
			header("Location: /result.php?page=update_photo&id=$pid&error=There was an error uploading your image. Please try again.");
		}
	}
?>

Merci pour vos aides

Eléphanteau du PHP | 41 Messages

29 août 2014, 14:10

hello

Nevermind,
j'ai trouve ce qui clochait, sur le fichier de verification j'ai ajoute un point sur le chemin donnant sur le dossier image comme ceci :

./membres/users/pics/

Ca marche nikel l'avatar s'upload tres bien
tout ca juste pour un point

Sinon ce qui m'a aider c'est en lisant sur topic ou Ryle disait : "....spécifier l'emplacement du répertoire de façon relative en utilisant "../" pour remonter dans un dossier parent."

php-debutant/move-uploaded-file-dans-do ... 58991.html

J'espere que cela aidera pour celui qui rencontre le meme probeleme

Merci au forum ;)