Jump to content

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;
}

?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.