Προς το περιεχόμενο

Πρόβλημα με Upload Photos (Thumbnails) PHP


mixalis8

Προτεινόμενες αναρτήσεις

Δημοσ.

xrisimopoio afton ton kodika

 

$sPhotoFileName = $_FILES['fotografia']['name']; // get client side file name

if ($sPhotoFileName) // file uploaded

{ $aFileNameParts = explode(".", $sPhotoFileName);

$sFileExtension = end($aFileNameParts); // part behind last dot

if ($sFileExtension != "jpg" && $sFileExtension != "JPEG" && $sFileExtension != "JPG" && $sFileExtension != "jpeg" && $sFileExtension != "Jpeg" && $sFileExtension != "Jpg" && $sFileExtension != "jPeg" && $sFileExtension != "jPg" && $sFileExtension != "jpEg" && $sFileExtension != "jpEG" && $sFileExtension != "jpeG") { die ("Choose a JPG for the photo"); } $nPhotoSize = $_FILES['fotografia']['size']; // size of uploaded file

if ($nPhotoSize == 0) { die ("Sorry. The upload of $sPhotoFileName has failed. Search a photo smaller than 200K, using the button."); } if ($nPhotoSize > 20480099) { die ("Sorry. The file $sPhotoFileName is larger than 200K. Advice: reduce the photo using a drawing tool."); } // read photo

$sTempFileName = $_FILES['fotografia']['tmp_name']; // temporary file at server side

$oTempFile = fopen($sTempFileName, "r");

$sBinaryPhoto = fread($oTempFile, fileSize($sTempFileName)); // Try to read image

$nOldErrorReporting = error_reporting(E_ALL & ~(E_WARNING)); // ingore warnings

$oSourceImage = imagecreatefromstring($sBinaryPhoto); // try to create image

error_reporting($nOldErrorReporting);

if (!$oSourceImage) // error, image is not a valid jpg

{ die ("Sorry. It was not possible to read photo $sPhotoFileName. Choose another photo in JPG format."); } }

 

$nWidth = imagesx($oSourceImage); // get original source image width

$nHeight = imagesy($oSourceImage); // and height // create small thumbnail

$nDestinationWidth = 320;

$nDestinationHeight = 320;

$oDestinationImage = imagecreatetruecolor($nDestinationWidth, $nDestinationHeight);

$oDestinationImage = imagecreate($nDestinationWidth, $nDestinationHeight);

imagecopyresized( $oDestinationImage, $oSourceImage, 0, 0, 0, 0, $nDestinationWidth, $nDestinationHeight, $nWidth, $nHeight); // resize the image

ob_start(); // Start capturing stdout.

imageJPEG($oDestinationImage); // As though output to browser.

$sBinaryThumbnail = ob_get_contents(); // the raw jpeg image data.

ob_end_clean(); // Dump the stdout so it does not screw other output.

 

 

 

$sBinaryThumbnail = addslashes($sBinaryThumbnail);

$imgData =addslashes (file_get_contents($_FILES['fotografia']['tmp_name']));

 

$now = date("d/m/y, g:i");

mysql_query('SET NAMES "GREEK"');

mysql_query("INSERT INTO Nea (id, date, epikefalida, keimeno, fotografia, sxolia, thumbnails) VALUES('0', '$now', '$epikefalida', '$keimeno', '$imgData', '$sxolia', '$sBinaryThumbnail')") or die(mysql_error());

mysql_query($sQuery, $connection);

 

 

ithela na testaro to kodika kai me megaliteres fotografies kai ebala san orio to 20480099... tespa...

 

eno me mia fotografia mikri den eixa problima me megales fotografies px 500KB eno ekane kanonika to thumbnail tin eikona tin ekobe px stin mesi... oso poio megali toso ligotero edixne...

tora mou perase apo to mialo oti ston pinaka mou den xoraei sto blob paidio....

 

ti orio dedomenon exei to blob????

Αρχειοθετημένο

Αυτό το θέμα έχει αρχειοθετηθεί και είναι κλειστό για περαιτέρω απαντήσεις.

  • Δημιουργία νέου...