Jump to content

Functions Help Needed (Again)


lpxxfaintxx

Recommended Posts

profilepic.php

 

$sessid = $_SESSION['id'];


$user = queryuser($sessid);

if ($user[profilepic] == "") {
$imgurl = "images/nophoto.jpg";
} else {
$imgurl = $user[profilepic];
}

if(isset($_FILES['upload'])){

if(preg_match('/[.](jpg)|(gif)|(png)$/', $_FILES['upload']['name'])){

$filename = $_FILES['upload']['name'];

$ext = pathinfo($filename, PATHINFO_EXTENSION);
$filename2 = $user[user_id];
$source = $_FILES['upload']['tmp_name'];
$target = $path_to_image_directory . $filename2 .'.'.$ext;

move_uploaded_file($source, $target);

createThumbnail($filename2,$ext);

}

 

 

 

 

functions.php

 

 

function createThumbnail($filename2,$ext) {

require 'config.php';

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



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

if($ox > 300){

$nx = $final_width_of_image;
$ny = floor($oy * ($final_width_of_image / $ox));

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

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

if(!file_exists($path_to_thumbs_directory)) {
  if(!mkdir($path_to_thumbs_directory)) {
           die("There was a problem. Please try again!");
  } 
       }

imagejpeg($nm, $path_to_thumbs_directory . $filename2 .'.'.$ext);
$tn = '<img src="' . $path_to_thumbs_directory . $filename2 .'.'.$ext . '" alt="image" />';
$tn .= '<br />Congratulations. Your file has been successfully uploaded, and a 	  thumbnail has been created.';
echo $tn;

} else {
}

 

 

 

Error: Warning: Missing argument 2 for createThumbnail(), called in /home/q94/public_html/alumnify.com/profilepic.php on line 30 and defined in /home/q94/public_html/alumnify.com/includes/classes.php on line 19

 

Any idea what I did wrong?

Link to comment
https://forums.phpfreaks.com/topic/134894-functions-help-needed-again/
Share on other sites

Yeah, he has a second param set, so there might be another error we can't see.. Just a hunch.

 

If you don't get anything, try echoing $ext and $filename2 before you use them to see if they are what you expect... if not, trace them back and find why.

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.