Dynadot Aftermarket: discover domain gems worth investing in. Visit our aftermarket.

[PHP] Image uploading

Namecheap AuctionsNamecheap Auctions
Namecheap AuctionsNamecheap Auctions
SpaceshipSpaceship
Watch

liam_d

The original NP Emo KidEstablished Member
Impact
25
I currently have this which works pretty dam well.
Although i want to allow more than just jpg files to be uploaded, i also want the names to be proper randomized as right now it keeps the same name so there could be many conflicts :(

PHP:
		$imagename = $_FILES['new_image']['name'];

		$source = $_FILES['new_image']['tmp_name'];

		$target = "images/uploads/".$imagename;

		move_uploaded_file($source, $target);

              

		$imagepath = $imagename;

		$save = "images/uploads/" . $imagepath; //This is the new file you saving

		$file = "images/uploads/" . $imagepath; //This is the original file



		list($width, $height) = getimagesize($file) ; 

                                                         

		$diff = $width;



		$save = "images/uploads/thumb_" . $imagepath; //This is the new file you saving

		$file = "images/uploads/" . $imagepath; //This is the original file



		list($width, $height) = getimagesize($file) ; 

                                                         

		$tn = imagecreatetruecolor(150, 150) ; 

		$image = imagecreatefromjpeg($file) ; 

		imagecopyresampled($tn, $image, 0, 0, 0, 0, 150, 150, $width, $height) ; 

                                                        

		imagejpeg($tn, $save, 100) ; 

		

		$sql = "UPDATE `listings` SET `screenshot` = '{$imagepath}', `thumbnail_screenshot` = 'thumb_{$imagepath}' WHERE `scriptid` = '{$_GET['lid']}'";

		

		mysql_query($sql);
 
0
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
Just change the $imagename parametre to change what it's called.

Perhaps more importantly, you're putting unescaped code directly into a SQL statement, you need to fix that.
 
0
Close
That is just a test file don't worry about the sql input only me using it.

And thanks.
 
0
Close
DomainEasy: flexible LTO options. Close more domain deals with financing.

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Switch between accounts
You can now stay logged in to more than one NamePros account in the same browser. Click your avatar, then "Accounts in this browser", to...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back