runnerjp Posted October 29, 2009 Share Posted October 29, 2009 <?php //error_reporting(E_ALL); //session_start(); require_once '../settings.php'; include "../info.php"; // sets username/id ect ?><link rel="stylesheet" type="text/css" href="http://www.runningprofiles.com/css/login.css"> <fieldset> <form action="<?php echo $_server['php-self']; ?>" method="post" enctype="multipart/form-data" id="something" class="uniForm"> <p align="center"> <input name="new_image" id="new_image" size="30" type="file" class="fileUpload" /> </p> <p align="center"><legend><strong>Description</strong></legend> <input type='text' name='udesc'><br /> <div align="center"> <div align="center"> <?php $album=$_GET['al']; If ($album == ''){ ?> <select style='width:150px;' name='album'> <?php $fetch = mysql_query("SELECT * FROM `photomain` where uid = '1'"); while ($album = mysql_fetch_array($fetch)) { echo "<option value='$album[id]'>$album[name]</option>"; } } ?> </select> <br /> </div> <button name="submit" type="submit" class="submitButton">Upload/Resize Image</button> </div> </form> <?php if(isset($_POST['submit'])){ if (isset ($_FILES['new_image'])){ $file_name = $_FILES['new_image']['name']; $getExt = explode ('.', $file_name); $file_ext = $getExt[count($getExt)-1]; // Adding extension verification $allowed_ext = "|jpg|png|gif|jpeg|svg|bmp|"; if (strpos($allowed_ext, "|".strtolower($file_ext)."|")===false) die("Extension: $file_ext is not allowed!"); // End extension verification $imagename = "$id.$file_ext"; $source = $_FILES['new_image']['tmp_name']; $chars = "abcdefghijklmnopqrstuvwxyz1234567890"; //available chars $uniqueurl = substr(str_shuffle($chars), 0, 5); // shuffles the string $chars and picks the first 5 $target = "http://www.runningprofiles.com/members/include/myimages/$uniqueurl.$file_ext"; move_uploaded_file($source, $target); $imagepath = $imagename; $save = "http://www.runningprofiles.com/members/include/myimages/thumbs/" . $imagepath; //This is the new file you saving $file = "http://www.runningprofiles.com/members/include/myimages/" . $imagepath; //This is the original file list($width, $height) = getimagesize($file) ; // Adding proportionate image resizing, with max values /* $modwidth = 200; $diff = $width / $modwidth; $modheight = $height / $diff; */ $max_w = 130; $max_h = 86; if($width <= $max_w && $height <= $max_h){ // if it fits $modheight = $height; $modwidth = $width; }else{ // Then resize $diff = ($width > $height) ? ($width/$max_w) : ($height/$max_h); // Check which is bigger, and fit it to that max value. This will prevent stretching (80x800) $modheight = $height / $diff; $modwidth = $width / $diff; } // End $tn = imagecreatetruecolor($modwidth, $modheight) ; $image = imagecreatefromjpeg($file) ; imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ; imagejpeg($tn, $save, 100) ; $today = date("F j, Y, g:i a"); $picurl = "myimages/$uniqueurl" . $_FILES["file"]["name"]; $add_pic = mysql_query("INSERT INTO `photos` (`desc`,`thumb_id`,`date`,`picurl`, `datetaken`,`uid`) VALUES ( '$udesc','$album', '$date','$picurl','$today','$id');") or die(mysql_error()); echo "done"; } } ?></fieldset> i seem to be getting a list of errors from my script above and i dont undertstand why as iv used the code elsewhere and it works fine... can any 1 suggest any thing to solve the errors? Warning: move_uploaded_file() [function.move-uploaded-file]: URL file-access is disabled in the server configuration in /home/runningp/public_html/members/include/albumpicupload.php on line 52 Warning: move_uploaded_file(http://www.runningprofiles.com/members/include/myimages/yhi2d.jpg) [function.move-uploaded-file]: failed to open stream: no suitable wrapper could be found in /home/runningp/public_html/members/include/albumpicupload.php on line 52 Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/php9DXghY' to 'http://www.runningprofiles.com/members/include/myimages/yhi2d.jpg' in /home/runningp/public_html/members/include/albumpicupload.php on line 52 Warning: getimagesize() [function.getimagesize]: URL file-access is disabled in the server configuration in /home/runningp/public_html/members/include/albumpicupload.php on line 58 Warning: getimagesize(http://www.runningprofiles.com/members/include/myimages/1.jpg) [function.getimagesize]: failed to open stream: no suitable wrapper could be found in /home/runningp/public_html/members/include/albumpicupload.php on line 58 Warning: imagecreatetruecolor() [function.imagecreatetruecolor]: Invalid image dimensions in /home/runningp/public_html/members/include/albumpicupload.php on line 84 Warning: imagecreatefromjpeg() [function.imagecreatefromjpeg]: URL file-access is disabled in the server configuration in /home/runningp/public_html/members/include/albumpicupload.php on line 85 Warning: imagecreatefromjpeg(http://www.runningprofiles.com/members/include/myimages/1.jpg) [function.imagecreatefromjpeg]: failed to open stream: no suitable wrapper could be found in /home/runningp/public_html/members/include/albumpicupload.php on line 85 Warning: imagecopyresampled(): supplied argument is not a valid Image resource in /home/runningp/public_html/members/include/albumpicupload.php on line 86 Warning: imagejpeg(): supplied argument is not a valid Image resource in /home/runningp/public_html/members/include/albumpicupload.php on line 87 done Quote Link to comment https://forums.phpfreaks.com/topic/179491-solved-errors-with-uploadign-and-resizing-image/ Share on other sites More sharing options...
nadeemshafi9 Posted October 29, 2009 Share Posted October 29, 2009 handel th first error, url file access is disabled, so use a relative path ../../../../ or wotever Quote Link to comment https://forums.phpfreaks.com/topic/179491-solved-errors-with-uploadign-and-resizing-image/#findComment-947028 Share on other sites More sharing options...
nadeemshafi9 Posted October 29, 2009 Share Posted October 29, 2009 $target = "http://www.runningprofiles.com/members/include/myimages/$uniqueurl.$file_ext"; $save = "http://www.runningprofiles.com/members/include/myimages/thumbs/" . $imagepath; //This is the new file you saving $file = "http://www.runningprofiles.com/members/include/myimages/" . $imagepath; //This is the original file $tn = imagecreatetruecolor($modwidth, $modheight) ; $image = imagecreatefromjpeg($file) ; imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ; imagejpeg($tn, $save, 100) ; this wont doo mate, you need to start from var if its using ftp, and use relative paths if not, it dosent use ftp, so use relative paths eg from where you are right now ../../ or wherever you need to go Quote Link to comment https://forums.phpfreaks.com/topic/179491-solved-errors-with-uploadign-and-resizing-image/#findComment-947030 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.