[advanced search]
Results from the most recent live auction are here.
18 members in the live chat room. Join Chat!
Register Rules & FAQ NP$ Store Active Threads Mark Forums Read
Go Back   NamePros.Com > Design and Development > Programming
User Name
Password

Old 04-30-2008, 02:05 AM   · #1
liam_d
The original NP Emo Kid
 
liam_d's Avatar
 
Name: Liam Dawe
Location: Plymouth, UK
Trader Rating: (27)
Join Date: Jan 2005
Posts: 1,541
NP$: 16.00 (Donate)
liam_d is a name known to allliam_d is a name known to allliam_d is a name known to allliam_d is a name known to allliam_d is a name known to allliam_d is a name known to all
[PHP] image uploading

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 Code:
$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);


Please register or log-in into NamePros to hide ads
liam_d is offline   Reply With Quote
Old 04-30-2008, 08:24 AM   · #2
Daniel
Danltn.com
 
Daniel's Avatar
 
Name: Daniel Neville
Location: Danltn.com / Nottingham, UK
Trader Rating: (65)
Join Date: May 2007
Posts: 1,185
NP$: 681.56 (Donate)
Daniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond reputeDaniel has a reputation beyond repute
Ethan Allen Fund Ethan Allen Fund
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.
Daniel is offline   Reply With Quote
Old 05-01-2008, 03:02 AM   · #3
liam_d
The original NP Emo Kid
 
liam_d's Avatar
 
Name: Liam Dawe
Location: Plymouth, UK
Trader Rating: (27)
Join Date: Jan 2005
Posts: 1,541
NP$: 16.00 (Donate)
liam_d is a name known to allliam_d is a name known to allliam_d is a name known to allliam_d is a name known to allliam_d is a name known to allliam_d is a name known to all
That is just a test file don't worry about the sql input only me using it.

And thanks.
liam_d is offline   Reply With Quote
Reply

NamePros is a revenue sharing forum.

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


Site Sponsors
Get Your Site Linked at LinkedKeywords.com Hunting Moon
Advertise your business at NamePros
All times are GMT -7. The time now is 10:53 PM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0