Jump to content

Recommended Posts

i'm following a tutorial to create a gallery and it uses createThumbnail() in it's code, as far as i understand from authors explanation it's a GD function, but i keep getting an error:

Fatal error: Call to undefined function createThumbnail() in E:\WOS\www\gallery\add_album.php on line 16

What's wrong here?

Code:

<?php
require("config.php");
include("header.php");

if($_POST['submitted']) {
$albumName = $_POST['album'];
$description = $_POST['description'];
$imageName = $_FILES['image']['name'];
$tmpName = $_FILES['image']['tmp_name'];

$ext = strrchr($imageName, ".");
$newName = md5(mt_rand()).$ext;
$imgPath = ALBUM_IMG_DIR . $newName;

//resize
$result = createThumbnail($tmpName, $imgPath, THUMBNAIL_WIDTH);

if($result == false) {
	echo "error during upload.";
	exit();
}
if(!get_magic_quotes_gpc()) {
	$albumName = addslashes($albumName);
	$description = addslashes($description);
}
$query = "INSERT INTO tbl_album(al_name, al_description, al_image, al_date)
			VALUES('$albumName', '$description', '$newName', NOW())";
mysql_query($query) or die('Error, add album failed : ' .    mysql_error());

header("location: http://localhost/gallery/list_album.php");
exit();
}
?>

<form action="<?php $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data">
<ul id="form">
	<li><label for="album">Album Name:</label><input type="text" id="album" name="album" maxlength="64" /></li>
	<li><label for="description">Description:</label><textarea rows="5" cols="15" name="description"></textarea></li>
	<li>
		<label for="image">Image:</label>
		<input type="file" id="image" name="image" />
	</li>
	<li><input type="submit" name="submit" value="Add Album" /><input type="submit" name="cancel" value="cancel" /></li>
	<input type="hidden" name="submitted" value="true" />
</ul>
</form>
<?php
include("footer.php");
?>

 

here's is the exact line:  $result = createThumbnail($tmpName, $imgPath, THUMBNAIL_WIDTH);

 

THUMBNAIL_WIDTH equals to 60.

 

Thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/108087-solved-createthumbnail-error/
Share on other sites

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.