gerkintrigg Posted August 8, 2007 Share Posted August 8, 2007 I'm just playing with someone else's code and was wondering how to get details of a file that's already uploaded to my server into the $_FILES super global. the code I have is: ...$uploadedFileName = $_FILES['filename']['name']; if($_FILES['filename']['size'] > $maxSize) {... all the checks are done using this and I just want to parse all this info without the user having any control / knowledge of it at all. It's for an image upload script which has been built already, but I want lots of differing quality thumbnails to be generated, but the current code keeps asking the user to input size variables and path details to upload a file from their local machine. I hope my boggle makes sense to someone out there in cyber land. Am I approaching this all wrong? Can anyone help please? Regards, Trigg Quote Link to comment Share on other sites More sharing options...
poizn Posted August 8, 2007 Share Posted August 8, 2007 Hey man i'v just been fiddleing around with image uploading But I dont understand your "boggle" exactly? Could you explain exactly what you trying to do and what's not working? Quote Link to comment Share on other sites More sharing options...
gerkintrigg Posted August 8, 2007 Author Share Posted August 8, 2007 sure... I have a form at: http://www.nextdaygraphics.com/resize/resizeimage.php that takes an image from the hard drive and uploads it to the server, rescales it and then deletes the original. That all works lovely... (you'll have to trust me on that) the only issue is how to do all of that without uploading the image. You see my problem is that an image has already been uploaded using another script (and that then adds a watermark to the image). I'd really like to keep all that in place because it took forever to get that working properly. I just want to plug in this little bit of code so that it does all the watermark stuff first, then takes the path to the watermarked file and rescales it, then outputs it to a thumbnail folder. I have both chunks working okay from the hard drive, but I want the re-scaler script to work, not from the local machine, but from the server's path (stored in the database). my current code is: <?php include_once("ImageResizeFactory.php"); if(isset($_POST["hdnupload"])) { $maxSize = "1048576"; // 1MB upload size of the file. $width = 600; $height = 600; $allowedExtensions = array("jpg", "JPG", "JPEG","GIF","gif","BMP","bmp","png", "PNG"); $uploadedFileName = $_FILES['filename']['name']; if($_FILES['filename']['size'] > $maxSize) { $error = "File size cannot exceed 1MB"; } if(file_exists("uploadedfiles/" . $uploadedFileName)) { $error = "File with " . $uploadedFileName . " name is already present<br>"; } $extension = pathinfo($_FILES['filename']['name']); $extension = $extension["extension"]; foreach($allowedExtensions as $key=>$ext) { if(strcasecmp($ext, $extension) == 0) { $boolValidExt = true; break; } } if($boolValidExt) { if(empty($error)) { if(is_uploaded_file($_FILES['filename']['tmp_name'])) { copy($_FILES['filename']['tmp_name'], "uploadedfiles/" . $uploadedFileName); } } } else { $error = "Files with .$extension extensions are not allowed"; } if(empty($error)) { $srcFile = "uploadedfiles/" . $uploadedFileName; $destFile = "uploadedfiles/resize_" . $uploadedFileName; // Instantiate the correct object depending on type of image i.e jpg or png $objResize = ImageResizeFactory::getInstanceOf($srcFile, $destFile, $width, $height); // Call the method to resize the image $objResize->getResizedImage(); unlink($srcFile); unset($objResize); exit; } } ?> <FORM name="frmupload" method="POST" enctype="multipart/form-data"> <input type="file" name="filename"> <input type="submit" name="Submit" value="Submit"> <INPUT type="hidden" name="hdnupload" value="true"> <input name="width" type="hidden" value="5" size="5" maxlength="3"> <input name="height" type="hidden" value="5" size="5" maxlength="3"> </FORM> There are other includes, but I think they're not required to get this bit of code working. and the last 2 inputs are only there to test something totally unrelated. Quote Link to comment Share on other sites More sharing options...
poizn Posted August 8, 2007 Share Posted August 8, 2007 Excuse me if I dont understand what you saying fully (i'm new to forums), but from what I can gather, the bit of code you gave will be run after the water marking script (which uploads the image) is run. Right? So where is that code run? Somewhere higher up in the script you gave? Or is it on the client machine before they upload the picture? Quote Link to comment Share on other sites More sharing options...
gerkintrigg Posted August 8, 2007 Author Share Posted August 8, 2007 no the problem is that the watermarking script is run on the server, but the current code that i posted only resizes from an uploaded image, not from the result of the previous script. The code I posted is run after the watermarking script. I didn't post the watermarking script because all that's working as it should. All I need to work out is how to take the posted code above and change it so that the file that's resized can be taken from the server rather than uploaded from the local machine. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.