$php_mysql$ Posted June 30, 2011 Share Posted June 30, 2011 what am i doing wrong here friends? $target = "images_thumbs/"; $randomnum=rand(0000,9999); $target = $target.getnick_username($username).$randomnum; $target = $target . basename( $_FILES['uploaded']['name']) ; $ok=1; the image gets uploaded as username01234 the .jpg is not showing? Link to comment https://forums.phpfreaks.com/topic/240831-image-uploads-but-extension-not-showing/ Share on other sites More sharing options...
EdwinPaul Posted June 30, 2011 Share Posted June 30, 2011 And it shouldn't ! You used: basename(...). Read: http://php.net/manual/en/function.basename.php Link to comment https://forums.phpfreaks.com/topic/240831-image-uploads-but-extension-not-showing/#findComment-1236976 Share on other sites More sharing options...
requinix Posted June 30, 2011 Share Posted June 30, 2011 Just the .jpg or the entire original filename? Also: basename() won't remove the extension unless you specifically tell it to. Link to comment https://forums.phpfreaks.com/topic/240831-image-uploads-but-extension-not-showing/#findComment-1236978 Share on other sites More sharing options...
$php_mysql$ Posted June 30, 2011 Author Share Posted June 30, 2011 well i wished to rename the original file name i successfully did that now its just the .jpg extn which is missing from the uploaded file. im confused what im doing wrong please help me correct the code. :-) Link to comment https://forums.phpfreaks.com/topic/240831-image-uploads-but-extension-not-showing/#findComment-1236981 Share on other sites More sharing options...
EdwinPaul Posted June 30, 2011 Share Posted June 30, 2011 $target = "images_thumbs/"; $randomnum=rand(0000,9999); $target = $target.getnick_username($username).$randomnum; $aNew=pathinfo( $_FILES['uploaded']['name']); $target = $target . "." . $aNew['extension']; // $target = $target . basename( $_FILES['uploaded']['name']) ; $ok=1; Maybe this helps ? Link to comment https://forums.phpfreaks.com/topic/240831-image-uploads-but-extension-not-showing/#findComment-1236987 Share on other sites More sharing options...
$php_mysql$ Posted June 30, 2011 Author Share Posted June 30, 2011 this is strange its not showing any extension still file gets uploaded as username1324 without .jpg Link to comment https://forums.phpfreaks.com/topic/240831-image-uploads-but-extension-not-showing/#findComment-1236990 Share on other sites More sharing options...
$php_mysql$ Posted June 30, 2011 Author Share Posted June 30, 2011 fixed lol stupid field name was wrong :-D thanks. ok how do i resize the image? Link to comment https://forums.phpfreaks.com/topic/240831-image-uploads-but-extension-not-showing/#findComment-1236991 Share on other sites More sharing options...
$php_mysql$ Posted June 30, 2011 Author Share Posted June 30, 2011 this is a bit of coding i got for resizing image but im not sure how i would go using it with my codes above global $uploadPath; $imagepath = uploadFile($_FILES['image'], $uploadPath); // code to resize and save the original image $image = new SimpleImage(); $image->load($imagepath); $image->resize(204,250); $thumb_path = 'image_thumbs/thumb_'.$_FILES['image']['name']; $image->save($thumb_path); //image resize end unlink($imagepath); //delete the original file im actually refering to this article http://www.white-hat-web-design.co.uk/articles/php-image-resizing.php dont know how to use it. Link to comment https://forums.phpfreaks.com/topic/240831-image-uploads-but-extension-not-showing/#findComment-1236993 Share on other sites More sharing options...
requinix Posted June 30, 2011 Share Posted June 30, 2011 $thumb_path = 'image_thumbs/thumb_'.$_FILES['image']['name']; There's the filename. Incorporate the new stuff into that. Link to comment https://forums.phpfreaks.com/topic/240831-image-uploads-but-extension-not-showing/#findComment-1237003 Share on other sites More sharing options...
$php_mysql$ Posted June 30, 2011 Author Share Posted June 30, 2011 still confused, never actually used image resize before nor got too much idea i did this $image = new SimpleImage(); $image->load($imagepath); $image->resize(204,250); $image->save($_FILES["image"]["name"]); but i get Parse error: parse error in C:\wamp\www\edit\index.php on line 558 Link to comment https://forums.phpfreaks.com/topic/240831-image-uploads-but-extension-not-showing/#findComment-1237007 Share on other sites More sharing options...
$php_mysql$ Posted June 30, 2011 Author Share Posted June 30, 2011 here is my whole coding $target = "images_thumbs/"; $randomnum=rand(0000,9999); $target = $target.getnick_username($username).$randomnum; $target = $target.basename($_FILES['ad_image']['name']) ; $ok=1; if (file_exists("images_thumbs/" . $_FILES["ad_image"]["name"])) { echo "<p align=\"center\">"; echo $_FILES["file"]["name"] . "Oops file name already exists<br/> kindly rename your picture and upload again. <br/>"; echo "<a href=\"index.php?action=main&sid=$sid\">Home</a>"; echo "</p>"; }else{ $image = new SimpleImage(); $image->load($imagepath); $image->resize(204,250); $image->save($_FILES["image"]["name"]); //If everything is ok we try to upload it else{ if(move_uploaded_file($_FILES['ad_image']['tmp_name'], $target)){ echo "<p align=\"center\">"; echo "The file ". basename( $_FILES['uploadedfile']['name']). " Picture uploaded successfully.<br/><br/><b>$target <br/>"; echo "<a href=\"index.php?action=main&sid=$sid\">Home</a>"; echo "</p>"; } else{ echo "<p align=\"center\">"; echo "Sorry, there was a problem uploading your file.<br/>"; echo "</p>"; } } Link to comment https://forums.phpfreaks.com/topic/240831-image-uploads-but-extension-not-showing/#findComment-1237013 Share on other sites More sharing options...
EdwinPaul Posted July 1, 2011 Share Posted July 1, 2011 here is my whole coding $target = "images_thumbs/"; $randomnum=rand(0000,9999); $target = $target.getnick_username($username).$randomnum; $target = $target.basename($_FILES['ad_image']['name']) ; $ok=1; if (file_exists("images_thumbs/" . $_FILES["ad_image"]["name"])) { echo "<p align=\"center\">"; echo $_FILES["file"]["name"] . "Oops file name already exists<br/> kindly rename your picture and upload again. <br/>"; echo "<a href=\"index.php?action=main&sid=$sid\">Home</a>"; echo "</p>"; }else{ $image = new SimpleImage(); $image->load($imagepath); $image->resize(204,250); $image->save($_FILES["image"]["name"]); //If everything is ok we try to upload it else{ if(move_uploaded_file($_FILES['ad_image']['tmp_name'], $target)){ echo "<p align=\"center\">"; echo "The file ". basename( $_FILES['uploadedfile']['name']). " Picture uploaded successfully.<br/><br/><b>$target <br/>"; echo "<a href=\"index.php?action=main&sid=$sid\">Home</a>"; echo "</p>"; } else{ echo "<p align=\"center\">"; echo "Sorry, there was a problem uploading your file.<br/>"; echo "</p>"; } } Seeing this, I think you don't know what you are doing. Although suggested previously, your extension is still missing. The resize-class you mention re-saves the resized picture. If you give it a name as you do, you will never know where it will be saved. If you say 'Parse error: parse error in C:\wamp\www\edit\index.php on line 558' nobody but you can guess what line that is. You have to provide more information, and take the advices you get a bit more seriously. They are meant to help you. :-\ Link to comment https://forums.phpfreaks.com/topic/240831-image-uploads-but-extension-not-showing/#findComment-1237195 Share on other sites More sharing options...
$php_mysql$ Posted July 1, 2011 Author Share Posted July 1, 2011 my extension issue is .sover :-) now images gets uploaqded with the .jpg but yes about this resizing i surely do not know where and how to get it done Link to comment https://forums.phpfreaks.com/topic/240831-image-uploads-but-extension-not-showing/#findComment-1237233 Share on other sites More sharing options...
EdwinPaul Posted July 1, 2011 Share Posted July 1, 2011 Okay, I'll try to guide you through it: [*]from the site you mentioned, (http://www.white-hat-web-design.co.uk/articles/php-image-resizing.php) you copy ALL of the text from the first file (below 'The code') and save it on your computer with the name SimpleImage.php [*]In the top of your own php-file, the one where you are busy with uploading your picture, you enter: include('SimpleImage.php'); You may have to add a path to that file, depending on the location where you saved it. [*] At this moment that complete class SimpleImage is now part of your own coding. [*] At the moment you want to resize an image, that class wants to know 3 things: the name of the picture you want to resize, the size you want, and the name you want to give to the resize picture. [*] first you start the class with: $image = new SimpleImage(); // your copy of the class is now called $image [*] Now you tell that class the name of your picture: $image->load('picture.jpg'); // replace 'picture.jpg' with the name of your picture. This may also be a variable. [*] Next you tell the class what size you want: $image->resize(250,400); // take a guess ... [*] Now give the class the name of the resized picture and tell it to do it's job: $image->save('picture2.jpg'); // I think it is unwise to give it the same name. Got it now? Link to comment https://forums.phpfreaks.com/topic/240831-image-uploads-but-extension-not-showing/#findComment-1237243 Share on other sites More sharing options...
$php_mysql$ Posted July 1, 2011 Author Share Posted July 1, 2011 is this correct? $target = "images_thumbs/"; $randomnum=rand(00000000,99999999); $oldname = $target.$randomnum.getnick_id($id).$randomnum; $newname = $oldname.$randomnum.basename($_FILES['ad_image']['name']) ; $ok=1; $target= new SimpleImage(); $newname->load($newname); $newname->resize(204,250); $newname->save($target); guess not i get this error Fatal error: Call to a member function load() on a non-object in C:\wamp\www\edit\index.php Link to comment https://forums.phpfreaks.com/topic/240831-image-uploads-but-extension-not-showing/#findComment-1237264 Share on other sites More sharing options...
EdwinPaul Posted July 1, 2011 Share Posted July 1, 2011 is this correct? $target = "images_thumbs/"; $randomnum=rand(00000000,99999999); $oldname = $target.$randomnum.getnick_id($id).$randomnum; $newname = $oldname.$randomnum.basename($_FILES['ad_image']['name']) ; $ok=1; $target= new SimpleImage(); $newname->load($newname); $newname->resize(204,250); $newname->save($target); guess not i get this error Fatal error: Call to a member function load() on a non-object in C:\wamp\www\edit\index.php Did you include the complete class as I mentioned earlier? Put the next line after $oldname = $target.$randomnum.getnick_id($id).$randomnum; echo 'oldname='.$oldname.'<br/>'; and put this line after $newname = $oldname.$randomnum.basename($_FILES['ad_image']['name']) ; echo 'newname='.$newname.'<br/>'; Then you see what you made of it. Link to comment https://forums.phpfreaks.com/topic/240831-image-uploads-but-extension-not-showing/#findComment-1237279 Share on other sites More sharing options...
$php_mysql$ Posted July 1, 2011 Author Share Posted July 1, 2011 yes bro class in included already lemme try the echo Link to comment https://forums.phpfreaks.com/topic/240831-image-uploads-but-extension-not-showing/#findComment-1237281 Share on other sites More sharing options...
$php_mysql$ Posted July 1, 2011 Author Share Posted July 1, 2011 got this after echoing oldname=images_thumbs/96539306admin96539306 newname=images_thumbs/96539306admin9653930696539306Water lilies.jpg Link to comment https://forums.phpfreaks.com/topic/240831-image-uploads-but-extension-not-showing/#findComment-1237282 Share on other sites More sharing options...
EdwinPaul Posted July 1, 2011 Share Posted July 1, 2011 Now you can see what's wrong. $oldname=$_FILES['ad_image']['name']; $newname="images_thumbs/".rand(00000000,99999999).getnick_id($id).$_FILES['ad_image']['name']; $image= new SimpleImage(); $image->load($oldname); $image->resize(204,250); $image->save($newname); Link to comment https://forums.phpfreaks.com/topic/240831-image-uploads-but-extension-not-showing/#findComment-1237283 Share on other sites More sharing options...
$php_mysql$ Posted July 1, 2011 Author Share Posted July 1, 2011 did this $oldname = $target.$_FILES['ad_image']['name']; $newname = $oldname.$randomnum.basename($_FILES['ad_image']['name']) ; $ok=1; $image= new SimpleImage(); $image->load($oldname); $image->resize(204,250); $image->save($newname); and i get error Warning: getimagesize(images_thumbs/Water lilies.jpg) [function.getimagesize]: failed to open stream: No such file or directory in C:\wamp\www\edit\image_resize.php on line 14 Warning: imagesx() expects parameter 1 to be resource, null given in C:\wamp\www\edit\image_resize.php on line 46 Warning: imagesy() expects parameter 1 to be resource, null given in C:\wamp\www\edit\image_resize.php on line 49 Warning: imagecopyresampled() expects parameter 2 to be resource, null given in C:\wamp\www\edit\image_resize.php on line 68 Link to comment https://forums.phpfreaks.com/topic/240831-image-uploads-but-extension-not-showing/#findComment-1237287 Share on other sites More sharing options...
EdwinPaul Posted July 1, 2011 Share Posted July 1, 2011 Why did you add $target in front of the old name? The resize-class can't find the file in the location you provide. And why do you compose that newname the way you did? I gave you a reasonable new name. Link to comment https://forums.phpfreaks.com/topic/240831-image-uploads-but-extension-not-showing/#findComment-1237289 Share on other sites More sharing options...
$php_mysql$ Posted July 1, 2011 Author Share Posted July 1, 2011 oh yes i removed basename etc this is how i did $oldname = $_FILES['ad_image']['name']; $newname = $target.$randomnum.getnick_uid($uid).$_FILES['ad_image']['name'] ; $ok=1; $image= new SimpleImage(); $image->load($oldname); $image->resize(204,250); $image->save($newname); and the resize_image.php is in the same dir why is it not being found? lol crazy this is Link to comment https://forums.phpfreaks.com/topic/240831-image-uploads-but-extension-not-showing/#findComment-1237294 Share on other sites More sharing options...
EdwinPaul Posted July 1, 2011 Share Posted July 1, 2011 What can't be found? The class? Check the correct spelling (Case-sensitive !). The upload-file? Dit you enter something in the field on your form? Link to comment https://forums.phpfreaks.com/topic/240831-image-uploads-but-extension-not-showing/#findComment-1237300 Share on other sites More sharing options...
$php_mysql$ Posted July 1, 2011 Author Share Posted July 1, 2011 guess i better giveup just not happening Link to comment https://forums.phpfreaks.com/topic/240831-image-uploads-but-extension-not-showing/#findComment-1237379 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.