Jump to content

AdSpace

New Members
  • Posts

    1
  • Joined

  • Last visited

AdSpace's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hello all forum members: I am new here and I need help! I have a file that let the user upload a file to our server/script it should resize and save the file to our server folder, but the final file saved is 0 bytes I do have ImageMagik 6.8.0-4 installed on the server hosting I will post the file code below for review Thanks in advance to all ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <?php session_start(); session_register("sess_data"); include("engine.php"); //security check! are we logged in? if ($sess_name != ""){ // OK to continue \\ //Standard includes\\ secheader(); echo ("<br />"); bannerads(); echo ("<br />"); echo ("<a href='../members/index.php'><font size='4'><b>Return To Member Home</b></font></a><br /><br /"); if ($_SERVER['REQUEST_METHOD'] == "POST") { $uploaddir = "../splash_engine/photo/"; //step 1 get the file and see if it is a jpg\\ //*== get file extension (fn at bottom of script) ==*/ /*== checks to see if image file, if not do not allow upload ==*/ $pext = getFileExtension($imgfile_name); $pext = strtolower($pext); if (($pext != "jpg") && ($pext != "jpeg")) { echo ("<h3>"); print "ERROR - Image Extension Unknown.<br>"; print "<p>Please upload only a JPEG image with the extension .jpg or .jpeg ONLY<br><br>"; echo ("<br />"); echo ("</h3>"); echo $testmessage; echo ("<br />"); tads(); secfooter(); /*== delete uploaded file ==*/ unlink($imgfile); exit(); } //step 2 resize it\\ //-- RE-SIZING UPLOADED IMAGE /*== get size of image ==*/ if (filesize($imgfile) > 56600 || filesize($imgfile) < 2) { $imgsize = GetImageSize($imgfile); $width = $imgsize[0]; $height = $imgsize[1]; echo ("<br>"); echo $width; echo (" Width"); echo ("<br>"); echo $height; echo (" height"); echo ("<br>"); echo $filename . ': ' . filesize($imgfile) . ' bytes'; echo ("<br>"); error_level(); } else { $tmpimg = "temp".$ref.".jpg"; /*== RESIZE PROCESS 1. decompress jpeg image to pnm file (a raw image type) 2. scale pnm image 3. compress pnm file to jpeg image ==*/ /*== Step 1: djpeg decompresses jpeg to pnm ==*/ system("djpeg $imgfile >$tmpimg"); /*== Steps 2&3: scale image using pnmscale and then pipe into cjpeg to output jpeg file ==*/ system("pnmscale -xy 75 100 $tmpimg | cjpeg -smoo 10 -qual 50 >$imgfile"); /*== remove temp image ==*/ unlink($tmpimg); } //step3 define the file name\\ $newfile = $ref.".jpg"; $final_filename = $newfile; $upload=$filepaths.$newfile; //echo $upload." - filename"; // make sure resize has worked!\\ //animated gifs renamed will crash it!\\ if (filesize($imgfile) ==0 ){ echo ("<br>"); error_level(); } //step 4 - copy it over to server. if (!copy($imgfile, $upload)) { //email admin\\ //$file = '../splash_engine/photo/'.$ref.'.jpg'; if (file_exists($upload)) { } else { /*== if an error occurs the file could not be written, read or possibly does not exist ==*/ error_level(); } } //mail variables\\ $mailto = $adminmail ; $email = $sess_name; $name = "member ID ".$ref; $subject = $ref." Member Photo uploaded"; $yourname = $testmessage ; $formurl = $memberimage ; $messageproper = "This message was sent from:\n". "$yourname\n". "---------------------- $name ---------------\n\n" . "The image uploaded was $formurl\n". "If this breaks your rules, remove it with the Admin member photo tool.\n". "Otherwise no action is needed.\n". "\n\n----------------------------------------------------------------------\n" ; mail($mailto, $subject, $messageproper, "From: \"$name\" <$email>\nReply-To: \"$name\" $email>\nX-Mailer: POSH Splash Engine Version 1.1" ); /*== delete the temporary uploaded file ==*/ unlink($imgfile); } ?> </head> <body bgcolor="#FFFFFF"> <h2>Upload Your Image</h2> <br><?php images()?><br> <p><strong>Warning misuse of this facility will result in immediate termination of your account.</strong><br> <br> These include, but are not limited to: </p> <ul> <li>Any images of an inappropriate nature.</li> <li>Racist symbolism.</li> <li>Any file that is copyrighted or any copyright logos.<br> </li> </ul> <p align="center"><strong>Please note we only accept images of H100 x W75 pixels in JPG format.<br> </strong><strong>Larger images will be automatically resized, it is your responsibilty to ensure that your image will appear correctly if resized. </strong></p> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST" enctype="multipart/form-data"> <input type="hidden" name="MAX_FILE_SIZE" value="500000"> <p>Upload Image: <input type="file" name="imgfile"><br> <font size="1">Click browse to upload a local file</font><br> <br> <input type="submit" value="Upload Image"> </form> <?php echo ("<br />"); echo $testmessage; echo ("<br />"); tads(); secfooter(); // end the main function for logge in users// } else { // log them them smart arses out! echo("<meta HTTP-EQUIV='REFRESH' content='2; url=$self_url'>"); echo("<h2><b><center>Invalid User! - Error 3</h2></b></center><br>"); http_redirect ($self_url); exit; } ?> <?php /*== FUNCTIONS ==*/ function getFileExtension($str) { $i = strrpos($str,"."); if (!$i) { return ""; } $l = strlen($str) - $i; $ext = substr($str,$i+1,$l); return $ext;} function error_level() { echo ("<h3>"); echo ("The file size is too big to be resized. Please try again with a smaller image"); echo ("<br />"); echo ("OR it was a not a true JPEG. <br>Please try again with a smaller file in the correct format."); echo ("<br />"); echo ("</h3>"); echo $testmessage; echo ("<br />"); tads(); secfooter(); exit(); } ?>
×
×
  • 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.