Alright i have implemented the thumbnail snippet that i found on this site, however i am still not able to create the thumb itself, the file uploads as it should but no thumb is created , here is my code. i only used the make thumb function for the first file, just to test it.
require "connect.php";
function make_thumb($imagefile, $new_w=100, $new_h=75)
{
// get source image info.
$img_data=getimagesize($imagefile);
$src_w=$img_data[0];
$src_h=$img_data[1];
// get source image
$src_img=ImageCreateFromJPEG($imagefile) or die ("Cannot open source");
// create a target image
$dst_img=imagecreate($new_w,$new_h);
// create the thumbnail
imagecopyresized($dst_img,$src_img, 0, 0, 0, 0, $new_w, $new_h, $src_w,$src_h);
// switch to subdir.
chdir("thumbs");
// if the image already exists blow it away.
if ( file_exists("thumb_".$imagefile) )
{
unlink("thumb_".$imagefile);
}
// I use thumb_ to show that it is a thumbnail.
// save the new image as a png.
imagejpeg($dst_img,"thumb_".$imagefile);
// free up the memory.
ImageDestroy($src_img);
ImageDestroy($dst_img);
}
$sql = "INSERT INTO `articles` ( `author_id` , `title` , `full` , `section`) VALUES ('$author_id', '$title', '$full', '$section')";
mysql_query($sql,$db);
$files = 0;
$conn_id = ftp_connect('217.160.226.75');
if (!$conn_id)
die("Could not find ftp server!\n");
$login_result = ftp_login($conn_id,$ftpuser,$ftppass);
if (!$login_result)
die("Could not authorize login!\n");
ftp_chdir($conn_id, "pics/");
$mode= ftp_pasv($conn_id, 1);
$sql2 = "SELECT id FROM articles WHERE author_id = '$author_id' AND full = '$full'";
$result2 = mysql_query($sql2,$db);
$row = mysql_fetch_row($result2);
if ($file != "")
{
$dest = "pic.".$section.".".$row[0].".".$author_id.".jpg";
$upload = ftp_put($conn_id, $dest, $file, FTP_BINARY);
if ($upload)
$files++;
make_thumb("pics/pic.".$section.".".$row[0].".".$author_id.".jpg", 100, 75);
}
if ($file2 != "")
{
$dest = "pic.".$section.".".$row[0].".".$author_id."_2.jpg";
$upload = ftp_put($conn_id, $dest, $file2, FTP_BINARY);
if ($upload)
$files++;
}
if ($file3 != "")
{
$dest = "pic.".$section.".".$row[0].".".$author_id."_3.jpg";
$upload = ftp_put($conn_id, $dest, $file3, FTP_BINARY);
if ($upload)
$files++;
}
if ($file4 != "")
{
$dest = "pic.".$section.".".$row[0].".".$author_id."_4.jpg";
$upload = ftp_put($conn_id, $dest, $file4, FTP_BINARY);
if ($upload)
$files++;
}
if ($file5 != "")
{
$dest = "pic.".$section.".".$row[0].".".$author_id."_5.jpg";
$upload = ftp_put($conn_id, $dest, $file5, FTP_BINARY);
if ($upload)
$files++;
}
if ($file6 != "")
{
$dest = "pic.".$section.".".$row[0].".".$author_id."_6.jpg";
$upload = ftp_put($conn_id, $dest, $file6, FTP_BINARY);
if ($upload)
$files++;
}
//$sql5 = "UPDATE `articles` SET `pics` = '$files' WHERE `id` = '$row[0]'
ftp_close($conn_id);
echo "Pictures Added!<br><a href='admin.php'>Back to Panel</a>";
}