Current location: Hot Scripts Forums » Programming Languages » PHP » What script do I need for ths project? (Upload images script?)


What script do I need for ths project? (Upload images script?)

Reply
  #1 (permalink)  
Old 10-24-09, 01:32 PM
stevef22 stevef22 is offline
New Member
 
Join Date: Jul 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Question What script do I need for ths project? (Upload images script?)

I am working on a site for a tow truck company. They would like a script that has a back-end where employees can upload pictures of impounded cars and input a description about the vehicle. '

The script would auto resize the picture if necessary and populate a simple table on the site. The final look would be a list of cars with a brief description on the site and a date stamp.

What script is out there that can do this or were can I inquire about this from another JAVA/PERL expert?
If anyone can point me in the right direction or offer some quick services to help out I have a paypal verified acct. I can pay a little for this help.
Reply With Quote
  #2 (permalink)  
Old 10-24-09, 07:54 PM
End User's Avatar
End User End User is offline
Level II Curmudgeon
 
Join Date: Dec 2004
Posts: 3,027
Thanks: 14
Thanked 35 Times in 33 Posts
There are lots of upload scripts that will also resize an image. If you search Hotscripts you'll find quite a few.
__________________
I don't live on the edge, but sometimes I go there to visit.
-------------------------------------------------------------------------
Sanitize Your Data | Oracle Date & Substring Functions | Code Snippet Library | [url=http://www.codmb.com/Call Of Duty[/url]
Reply With Quote
  #3 (permalink)  
Old 10-30-09, 05:25 PM
Jcbones Jcbones is offline
Aspiring Coder
 
Join Date: Mar 2009
Location: North Carolina, USA
Posts: 516
Thanks: 5
Thanked 47 Times in 44 Posts
You could modify this to fit your needs, it is basic and easy to understand. More sanitation and validation could be used.

PHP Code:

$setWidth 300;

$setHeight 300;

if(isset(
$_POST['upload'])) {
$message mysql_real_escape_string(strip_tags($_POST['message']));
$hobby mysql_real_escape_string(strip_tags($_POST['hobby']));        
        if(
$_FILES["file"]["size"] > 900000) { $content .= "File is to large, submit a smaller image!"; }
        elseif(empty(
$_FILES["file"]["name"])) { $content .= "No File Uploaded!"; }
                        else
                            {
                                if (((
$_FILES["file"]["type"] == "image/gif")
                                    || (
$_FILES["file"]["type"] == "image/jpeg")
                                    || (
$_FILES["file"]["type"] == "image/pjpeg")
                                    || (
$_FILES["file"]["type"] == "image/png")
                                    || (
$_FILES["file"]["type"] == "image/jpg")
                                    || (
$_FILES["file"]["type"] == "image/x-png"))
                                    && (
$_FILES["file"]["size"] < 900000))
                                        {
                                        
$image str_replace(' ','_',$_FILES["file"]["name"]);
                                        
$image str_replace("'",'',$image);
                                            if (
$_FILES["file"]["error"] > 0)
                                                {
                                                    
$content .=  "Return Code: " $_FILES["file"]["error"] . "<br />";
                                                }
                                            else
                                                {
                                                    
                                                    if (
file_exists("images/" $_FILES["file"]["name"]))
                                                        {
                                                                
$content .=  $_FILES["file"]["name"] . " already exists. Upload cancelled!<br/>Image path saved.";
                                                        }
                                                    else
                                                        {
                                                                
$uploadedfile $_FILES["file"]["tmp_name"];
                                                                
$size getimagesize($uploadedfile);
                                                                
$type $size['mime'];
                                                                
$width $size[0];
                                                                
$height $size[1];
                                                                       if(
$height $setHeight || $width $setWidth)
                                                                            { 
                                                                                
$newwidth=$setWidth;
                                                                                
$newheight=($height/$width)*$setWidth;
                                                                                
$tmp=imagecreatetruecolor($newwidth,$newheight);
                                                                                
$filename "images/$image";
                                                                                
                                                                                    if(
$size[2] == IMAGETYPE_GIF)
                                                                                        {
                                                                                            
$src imagecreatefromgif($uploadedfile);
                                                                                            
imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
                                                                                            
imagegif($tmp,$filename,100);
                                                                                        }
                                                                                    elseif(
$size[2] == IMAGETYPE_JPEG)
                                                                                        {
                                                                                            
$src imagecreatefromjpeg($uploadedfile);
                                                                                            
imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
                                                                                            
imagejpeg($tmp,$filename,100);
                                                                                        }
                                                                                    elseif(
$size[2] == IMAGETYPE_PNG
                                                                                        {
                                                                                            
$src imagecreatefrompng($uploadedfile);
                                                                                            
imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
                                                                                            
imagepng($tmp,$filename,9);
                                                                                        }
                                                                                
$content .=  "Image has been resized to $newwidth X $newheight<br/>";
                                                                            
imagedestroy($src);
                                                                            
imagedestroy($tmp);
                                                                            }
                                                                        else
                                                                            {      
                                                                                 
move_uploaded_file($uploadedfile"images/$image");                                                                                  
                                                                            }
                                                
                                                    }
                                                }
                                            
                                        }
                                    else { 
$content .=  "Invalid file"; }
                            }
        
$image mysql_real_escape_string($image);
        
$imageUpload = (isset($image)) ?  ",`image`=    '$image' " NULL;
        
$update "UPDATE `bio` SET `message` = '$message', `hobby` = '$hobby$imageUpload WHERE `id` = '$id'";
        
        
mysql_query($update) or die(mysql_error());

You will need to change the Database lines, but I left those in to show you a working script. Don't worry, it is from an old project. Use it as you will.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Raffle/Lottery Script (Very profitable!), Coded it myself. Voltaire General Advertisements 2 01-02-06 11:55 PM
PHP MP3 upload script - Paid project recedo Job Offers & Assistance 4 12-20-05 07:02 AM
Login and Upload Script JamesLake Database 0 03-27-05 05:27 AM
Looking for a script to upload images in a database. boskyvora PHP 2 06-16-03 04:18 AM


All times are GMT -5. The time now is 08:01 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.