buknoii Posted March 3, 2010 Share Posted March 3, 2010 Hi there! I've been developing a simple website wherein users on my website can upload their picture, once it is uploaded it will be renamed according to time and its width resized to 470px. I have been success working on it on my local computer but once I uploaded it on my webhosting service, the resizing script doesnt work. Please check my code below <?php $userid=$_POST["userid"]; include("dbconnect.php"); $result = mysql_query("select * from community_user_info where user_xid='$userid' ") or die (mysql_error()); while ($row = mysql_fetch_array($result)) { echo $row["user_xid"]; $user_id = $row["user_xid"]; #echo "<br>-->".$user_id."<br>"; } mysql_free_result($result); ?> <?php $target_path = "photos/"; $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; } else { echo "There was an error uploading the file, please try again!"; } ?> <br><br> <?php ?> <Br><br> <? $newfilename= date(("ydjGHs")); $oldWD = getcwd(); $path="photos"; chdir($path); rename("".basename( $_FILES['uploadedfile']['name'])."","".$user_id."-".$newfilename.".jpg"); echo "<input type='text' value='".$user_id."-".$newfilename.".jpg"."'><br>"; chdir($oldWD); ?> <br><br> <?php echo $photo = $user_id."-".$newfilename.".jpg"; chmod("photos/".$photo."", 0755); mysql_query("INSERT INTO community_user_photo (user_id,user_photo) VALUES ('$user_id','$photo') ") or die(mysql_error()); ?> <h2>photo added</h2> <br><Br><Br><Br><Br> <?php // File and new size $filename = "photos/".$photo; //echo($filename); // Get new sizes list($width, $height) = getimagesize($filename); //figure out height ratios $newwidth = 470; $newheight = ($newwidth/$width) * $height; echo "new height -->".$newheight."<br>"; // Load $thumb = imagecreatetruecolor($newwidth, $newheight); $source = imagecreatefromjpeg($filename); echo "thumb -->".$thumb."<br>"; echo "thumb -->".$source."<br>"; // resize imagecopyresampled($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); // Save the image as 'mynewpic.jpg' imagejpeg($thumb, ''.$filename,85); // Free up memory imagedestroy($thumb); ?> Any help or tips would be appreciated. Link to comment https://forums.phpfreaks.com/topic/194031-php-image-upload-problem/ Share on other sites More sharing options...
teamatomic Posted March 3, 2010 Share Posted March 3, 2010 Does the server allow the use of short tags? You use standard php tags except for one part. Also it might be a path problem. Try using absolute paths. Link to comment https://forums.phpfreaks.com/topic/194031-php-image-upload-problem/#findComment-1021046 Share on other sites More sharing options...
lAZLf Posted March 3, 2010 Share Posted March 3, 2010 I'm almost certain that if that's the problem, then it's a problem with the path. Does your server have the folder "photos/"? Link to comment https://forums.phpfreaks.com/topic/194031-php-image-upload-problem/#findComment-1021058 Share on other sites More sharing options...
buknoii Posted March 3, 2010 Author Share Posted March 3, 2010 thanks for the reply.. i tried changing the path from photos/ to var/www/html/community/photos but still no luck i heard that i need to chech my gd library?? whats a gd library? also what are the short tags that i used in my script? i just copied and paste some of this script so i really dont have idea what wrong with the script... thanks Link to comment https://forums.phpfreaks.com/topic/194031-php-image-upload-problem/#findComment-1021127 Share on other sites More sharing options...
teamatomic Posted March 3, 2010 Share Posted March 3, 2010 phpinfo() will tell you about GD. regular tag <?php ?> short tag <? ?> HTH Teamatomic Link to comment https://forums.phpfreaks.com/topic/194031-php-image-upload-problem/#findComment-1021139 Share on other sites More sharing options...
buknoii Posted March 4, 2010 Author Share Posted March 4, 2010 i tried to check my hosting service and it produces this kind of output Array ( [0] => libxml [1] => xml [2] => wddx [3] => tokenizer [4] => sysvshm [5] => sysvsem [6] => sysvmsg [7] => standard [8] => SimpleXML [9] => sockets [10] => SPL [11] => shmop [12] => session [13] => Reflection [14] => pspell [15] => posix [16] => pcntl [17] => mime_magic [18] => iconv [19] => hash [20] => gmp [21] => gettext [22] => ftp [23] => exif [24] => date [25] => curl [26] => ctype [27] => calendar [28] => bz2 [29] => zlib [30] => pcre [31] => openssl [32] => dbase [33] => gd [34] => imap [35] => ldap [36] => mbstring [37] => mysql [38] => mysqli [39] => PDO [40] => pdo_mysql [41] => pdo_sqlite ) Link to comment https://forums.phpfreaks.com/topic/194031-php-image-upload-problem/#findComment-1021161 Share on other sites More sharing options...
teamatomic Posted March 4, 2010 Share Posted March 4, 2010 go here. It will tell you. http://www.dagondesign.com/files/gd-test.txt HTH Teamatomic Link to comment https://forums.phpfreaks.com/topic/194031-php-image-upload-problem/#findComment-1021168 Share on other sites More sharing options...
buknoii Posted March 4, 2010 Author Share Posted March 4, 2010 anyone here got a good image resize script? Link to comment https://forums.phpfreaks.com/topic/194031-php-image-upload-problem/#findComment-1021176 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.