sGraphics1 Posted July 1, 2010 Share Posted July 1, 2010 Hello, I am new to this board and to php, I would like help with this code i've been working on. I have this working for pdf's uploads but now I need it to work for jpg's. I need it to rename and resize a jpg, and put it into the 'images' directory. I can help someone in return with Photoshop, Illustrator, swish or flashactionscript. Thanks so much! [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/206455-simple-but-im-new-to-php/ Share on other sites More sharing options...
Pikachu2000 Posted July 1, 2010 Share Posted July 1, 2010 You're more likely to get a response by posting the code within . . . tags, rather than as an attachment. Many people won't download an attachement. Link to comment https://forums.phpfreaks.com/topic/206455-simple-but-im-new-to-php/#findComment-1079991 Share on other sites More sharing options...
sGraphics1 Posted July 1, 2010 Author Share Posted July 1, 2010 Ok, I thought I did that but let me try again, thanks! Here is the code: <body bgcolor="#032026" text="#CCCCCC" link="#FFFFFF" vlink="#CCCCCC" alink="#CCCCCC"> <div align="left"><img name="AuraUpdates" src="http://www.auraupdates.com/images/Aura-Logo-Upload.gif" width="224" height="112" alt="Aura Updates"> </div> <?php echo "<title>Aura Updates file upload</title>"; echo "<div align=\"left\"><b>Aura Updates</b><br>"; echo "<h1 align=\"left\">File Upload</h1>"; echo "<div align=\"left\"><i>This may take a few minutes depending on your connection speed and file size. Please wait for a confirmation.</i><br><br>"; echo "<div align=\"left\">"; echo "<style type=\"text/css\"> BODY{font-family:Verdana, Arial, Helvetica, sans-serif} </style>"; // ============== // Configuration // ============== // Begin changes: 1) $uploaddir variable to set the directory the file will upload to 2) $aura_update Varialbe, 2) $aura_update2 Varialbe $uploaddir = "images"; // Where you want the files to upload to - Important: Make sure this folders permissions is 0777! NOTE: there is a forward slash "/" added to this directory farther down in the code $allowed_ext = "gif, jpg, jpeg"; // These are the allowed extensions of the files that are uploaded $max_size = "4000000"; // 50000 is the same as 50kb $max_height = "349"; // This is in pixels, this is for jpgs and images not pdf/html $max_width = "328"; // This is in pixels, this is for jpgs and images not pdf/html $aura_update = "Ad4"; // This is used for the success response only, it is not required for this script to work $aura_update2 = "ad4.jpg"; // NOT USING FOR PICTURES!!!!!!! Code has been turned to 'comments' with '//' below. This is used be the Check Name script to verify the correct file name //--------------------------------------------------------------------------------------------------------------------------END CHANGES // Check Entension $extension = pathinfo($_FILES['img1']['name']); $extension = $extension[extension]; $allowed_paths = explode(", ", $allowed_ext); for($i = 0; $i < count($allowed_paths); $i++) { if ($allowed_paths[$i] == "$extension") { $ok = "1"; } } // Check Name // if ($_FILES['img1']['name'] != "$aura_update2") { // print "FAILURE! Incorrect file, press back in your browser to try again.<br><br>Possible reasons for this failure:<br> // <i>-incorrect upper or lower case letters<br> // -spelling error<br> // -unacceptable file type</i><br> // <br> // (ERROR CODE: AU003)"; // exit; // } // Check File Size if ($ok == "1") { if($_FILES['img1']['size'] > $max_size) { print "FAILURE! File size is too big, press back in your browser to try again.<br><br>(ERROR CODE: AU001)"; exit; } // Check Height & Width list($width, $height, $type, $w) = getimagesize($_FILES['img1']['tmp_name']); if($width > $max_width || $height > $max_height) { print "FAILURE! File height and/or width are too big, press back in your browser to try again.<br><br>(ERROR CODE: AU002)"; exit; } // ============== // Upload Part // ============== if(is_uploaded_file($_FILES['img1']['tmp_name'])) { move_uploaded_file($_FILES['img1']['tmp_name'],$uploaddir.'/'.$_FILES['img1']['name']); } print "SUCCESS! The $aura_update page of your website has been updated."; } else { print "FAILURE! Incorrect file, press back in your browser to try again."; } ?> Link to comment https://forums.phpfreaks.com/topic/206455-simple-but-im-new-to-php/#findComment-1079999 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.