Image upload features

Hello everyone, I built a car dealership site for a friend and was wondering if you guys may be able to help me figure out a few image upload features.

I have it to where he can upload 6 images with every car he enters into the online DB, but I would like to have it auto re size all images he uploads prior to them being placed into their folder on the web server.

Here is my code, any help and/or advice would be greatly appreciated. and If you guys see that its just all around bad code, please don’t hold back, i’ll never learn without help and criticism :slight_smile:

[php]<form action="" method=“post” id="_form" name="_form" enctype=“multipart/form-data”>

Year:

  Make:

  Model:


Style:

  Mileage:

  Color


Retail Price:


Front:


Rear:



Left:


Right:



Interior Front:


Interior Rear:



"; [/php]

All I see is a form. What have you attempted as far as uploading and resizing?

I am terribly sorry, I pasted the wrong page. This is the page that lets him add new cars to the DB. As for what ive tried so far. I was trying to follow the phpacademy tutorial on the topic, but was unable to actually make it apply here, as I am still not quite that good at this yet. and was also pointed to this link http://www.9lessons.info/2009/03/upload-and-resize-image-with-php.html, but again, was unable to make that apply to what I have already written. So any advice or direction would be greatly appreciated sir.

[php]<?php
include ‘core/init.php’;
protect_page();
include ‘includes/overall/overallheader.php’;
include(‘connection.php’);
?>

<?php include 'includes/admin_menu.php'; ?> <?php if (isset($_POST['submit'])) { echo "

Vehicle Successfully Added!

"; } ?>

Add New Vehicle

Year:
  Make:
  Model:
Style:
  Mileage:
  Color:
Retail Price:


Vehicle Images

Front:
Rear:
Left:
Right:
Interior Front:
Interior Rear:

<?php if(isset($_POST['submit'])) { if(is_uploaded_file($_FILES['front']['tmp_name'])) { $name = $_FILES['front']['name']; $tmp_name = $_FILES['front']['tmp_name']; $location = "front/$name"; move_uploaded_file($tmp_name,$location); } else{$location = 'front/default.jpg';} if(is_uploaded_file($_FILES['rear']['tmp_name'])) { $name = $_FILES['rear']['name']; $tmp_name = $_FILES['rear']['tmp_name']; $location2 = "rear/$name"; move_uploaded_file($tmp_name,$location2); } else{$location2 = 'rear/default.jpg';} if(is_uploaded_file($_FILES['left']['tmp_name'])) { $name = $_FILES['left']['name']; $tmp_name = $_FILES['left']['tmp_name']; $location3 = "left/$name"; move_uploaded_file($tmp_name,$location3); } else{$location3 = 'left/default.jpg';} if(is_uploaded_file($_FILES['right']['tmp_name'])) { $name = $_FILES['right']['name']; $tmp_name = $_FILES['right']['tmp_name']; $location4 = "right/$name"; move_uploaded_file($tmp_name,$location4); } else{$location4 = 'righ/defautlt.jpg';} if(is_uploaded_file($_FILES['intfront']['tmp_name'])) { $name = $_FILES['intfront']['name']; $tmp_name = $_FILES['intfront']['tmp_name']; $location5 = "intfront/$name"; move_uploaded_file($tmp_name,$location5); } else{$location5 = 'intfront/defautlt.jpg';} if(is_uploaded_file($_FILES['intrear']['tmp_name'])) { $name = $_FILES['intrear']['name']; $tmp_name = $_FILES['intrear']['tmp_name']; $location6 = "intrear/$name"; move_uploaded_file($tmp_name,$location6); } else{$location6 = 'intrear/defautlt.jpg';} $_year = mysql_real_escape_string($_POST['year']); $_make = mysql_real_escape_string($_POST['make']); $_model = mysql_real_escape_string($_POST['model']); $_style = mysql_real_escape_string($_POST['style']); $_mileage = mysql_real_escape_string($_POST['mileage']); $_color = mysql_real_escape_string($_POST['color']); $_rprice = mysql_real_escape_string($_POST['rprice']); $sql="INSERT INTO `veh` SET `year`='$_year', `make`='$_make', `model`='$_model', `style`='$_style', `mileage`='$_mileage', `color`='$_color', `rprice`='$_rprice', `front`='$location', `rear`='$location2', `left`='$location3', `right`='$location4', `intfront`='$location5', `intrear`='$location6'"; if (!mysql_query($sql)) { die('Error: ' . mysql_error()); } mysql_close($con); } ?>
<?php include 'includes/overall/overallfooter.php'; ?>[/php]
Sponsor our Newsletter | Privacy Policy | Terms of Service