Jump to content

Uploading photos problem !!


webtuto

Recommended Posts

hi ,

i made a website where the admin can add photos to his page like an image gallery

so there are two pages where the admin is able to ad d these photos

the first one , everything is OK , the photo get uploaded succusfuly

 

but on the other page the upload fail !!!!!!!

 

even if its the same code

i gave chmod777 to the photos file

any help is appreciated thanks

 

Link to comment
https://forums.phpfreaks.com/topic/161369-uploading-photos-problem/
Share on other sites

the problem is not frrom the code

the problem is from something else

because i have two pages

 

the first one this code work succusfuly

and the other one no ?

and in my computer the two of theme WORKED

but when i host it on my host , it didnt wanna upload the photo

you see the problem ??

thats the code

 

	$width = 110;
	$height = 83;
	$thumb = "thumbs/";
 	$tmp = $_FILES['photo']['tmp_name'];
	$name = $_FILES['photo']['name'];
	$destination = "photos/";

	$upload = move_uploaded_file($tmp , "$destination$name");	

	createThumbnail($name);

if($upload) {

	echo "<br />";
	echo "[ <a href='../showit.php?id=$_GET[id]'>Retourner ]</a>";
}

it gives this error

Notice: Undefined variable: tn in /home2/gozikcom/public_html/webzik/maison/functions/functions1.php on line 36

 

here is the function code

 

<?php
function createThumbnail($name) {
$destination = "photos/";
$width = 110;
$height = 83;
$thumb = "thumbs/";


require 'includes/config.php';

if(preg_match('/[.](jpg)$/', $name)) {
	$im = imagecreatefromjpeg($destination . $name);
} else if (preg_match('/[.](gif)$/', $name)) {
	$im = imagecreatefromgif($destination . $name);
} else if (preg_match('/[.](png)$/', $name)) {
	$im = imagecreatefrompng($destination . $name);
}

$ox = imagesx($im);
$oy = imagesy($im);

$nx = $width;
$ny = $height;

$nm = imagecreatetruecolor($nx, $ny);

imagecopyresized($nm, $im, 0,0,0,0,$nx,$ny,$ox,$oy);

if(!file_exists($thumb)) {
  if(!mkdir($thumb)) {
           die("Y'as un probleme , essaye encore!");
  } 
       }

imagejpeg($nm, $thumb . $name);
echo $tn;
}

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.