It’s inserting into the db all but the image information. I’ve fixed this once before but I don’t know what’s going on with it now…any help appreciated
The upload form…
[php]function postingForm() {
echo ’
Fields marked with * are required for your posting to be seen! Without these fields your posting may not show up.
*
<!–[if IE]>
Posting Title:
<br />
<![endif]-->
<input type="text" id="title" name="title" placeholder="Posting Title" required />
<!--[if IE]>
<br />
<![endif]-->
<b>*</b>
<!--[if IE]>
Address:
<br />
<![endif]-->
<input type="text" id="address" name="address" placeholder="Address" required/><br />
<b>*</b>
<!--[if IE]>
Description:
<br />
<![endif]-->
<textarea id="description" name="description" placeholder="Enter details about your sale here!" required></textarea><br />
<br>
<table id="posting_special_details">
<tr>
<td>
<b>*</b>
<select id="city" name="city" required>
<optgroup label="Select City">';
if(isset($_GET['city_pass'])){
echo "<option selected>".$_GET['city_pass']."</option>";
}
else {
$county_id=$_GET['county_id'];
$sqlCountySelect = "SELECT * FROM city WHERE county_id='$county_id' ORDER BY city";
$resultCountySelect = mysql_query($sqlCountySelect);
while($rowCountySelect = mysql_fetch_array($resultCountySelect)){
echo "<option>" . $rowCountySelect['city'] . "</option>";
}
}
echo '
</optgroup>
</select>
</td>
<td>
<select name="class">
<optgroup label="Select Type of Sale">
<option>Rummage Sale</option>
<option>Yard Sale</option>
<option>Garage Sale</option>
<option>Moving Sale</option>
<option>Estate Sale</option>
<option value="multi family">-- Multi Family --</option>
</optgroup>
</select>
</td>
<td>
<label class="underline">List as city wide sale?</label>
<br />
<label style="color:black" for="city_wide">Yes</label>
<input type="radio" name="city_wide" value="city_wide"/>
<label style="color:black" for="null">No</label>
<input type="radio" name="city_wide" value="" checked/>
</td>
<td>
<label>Want to add your own image?</label>
<br />
<input type="hidden" name="MAX_FILE_SIZE" value="10485760000">
<input type="file" name="file" id="file"/>
</td>
</tr>
</table>
<br />
<table id="date-time-post-table">
<caption><small>(Date format must be mm/dd/yyyy)</small></caption>
<!--[if IE]>
<tr>
<td class="day_start_ie_row">Day 1</td>
<td class="day_start_ie_row">Day 2</td>
<td class="day_start_ie_row">Day 3</td>
<td class="day_start_ie_row">Day 4</td>
</tr>
<tr>
<td class="align_bottom">Date:</td>
<td class="align_bottom">Date:</td>
<td class="align_bottom">Date:</td>
<td class="align_bottom">Date:</td>
</tr>
<![endif]-->
<tr>
<td>
<b>*</b><input id="datepicker" type="text" class="from" name="start_date" name="from" placeholder="Start Date" required pattern="^(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d$"/>
</td>
<td>
<input type="text" id="datepicker" class="from" name="start_date1" name="from" placeholder="Start Date" pattern="^(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d$"/>
</td>
<td>
<input type="text" class="from" name="start_date2" name="from" placeholder="Start Date" pattern="^(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d$"/>
</td>
<td>
<input type="text" class="from" name="start_date3" name="from" placeholder="Start Date" pattern="^(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d$"/>
</td>
</tr>
<tr>
<td>';
echo '
<b>*</b><select id="start_time" name="start_time" required>
<option label="Start Time"></option>';
echo selectTime();
echo '
</select>
<b>*</b><select id="end_time" name="end_time" required>
<option label="End Time"></option>';
echo selectTime();
echo '
</select>
</td>
<td>
<select id="start_time" name="start_time1">
<option label="Start Time"></option>';
echo selectTime();
echo '
</select>
<select id="end_time" name="end_time1">
<option label="End Time"></option>';
echo selectTime();
echo '
</select>
</td>
<td>
<select id="start_time" name="start_time2">
<option label="Start Time"></option>';
echo selectTime();
echo '
</select>
<select id="end_time" name="end_time2">
<option label="End Time"></option>';
echo selectTime();
echo '
</select>
</td>
<td>
<select id="start_time" name="start_time3">
<option label="Start Time"></option>';
echo selectTime();
echo '
</select>
<select id="end_time" name="end_time3">
<option label="End Time"></option>';
echo selectTime();
echo '
</select><br>
</td>
</tr>
</table>
<br />
<table>
<!--[if IE]>
<tr>
<td></td>
<td colspan="2">Email:</td>
<td colspan="2">Last four of phone #:</td>
</tr>
<![endif]-->
<tr>
<td>**<span class="red"><sub>*</sub></span></td>
<td><input type="email" name="email" size="45" placeholder="Enter email so you can edit/delete postings" required /></td>
<td>**<span class="red"><sub>*</sub></span></td>
<td><input type="text" size="20" maxlength="4" name="phone" placeholder="Last four of phone #" required /></td>
</tr>
</table>
<h4><i>--Please remember to keep your posting up-to-date. If your sale is over we ask that you remove it.--</i></h4>
</form>
<br />
** <small>We will not give your email to anyone for any reason. We use your email and last four of # for verification purposes only!';
}
[/php]
upload script…
[php]if(isset($_POST[‘submit’])){
$title=urldecode($_POST[‘title’]);
$description=urldecode($_POST[‘description’]);
$address=urldecode($_POST[‘address’]);
$city=urldecode($_POST[‘city’]);
$state=urldecode($_POST[‘state’]);
//Start date
$start_date=urldecode($_POST[‘start_date’]);
$end_date=urldecode($_POST[‘end_date’]);
$start_time=urldecode($_POST[‘start_time’]);
$end_time=urldecode($_POST[‘end_time’]);
//Start date 1
$start_date1=urldecode($_POST[‘start_date1’]);
$end_date1=urldecode($_POST[‘end_date1’]);
$start_time1=urldecode($_POST[‘start_time1’]);
$end_time1=urldecode($_POST[‘end_time1’]);
//Start date 2
$start_date2=urldecode($_POST[‘start_date2’]);
$end_date2=urldecode($_POST[‘end_date2’]);
$start_time2=urldecode($_POST[‘start_time2’]);
$end_time2=urldecode($_POST[‘end_time2’]);
//Start date 3
$start_date3=urldecode($_POST[‘start_date3’]);
$end_date3=urldecode($_POST[‘end_date3’]);
$start_time3=urldecode($_POST[‘start_time3’]);
$end_time3=urldecode($_POST[‘end_time3’]);
$class=urldecode($_POST['class']);
$city_wide=urldecode($_POST['city_wide']);
$email=addslashes(urldecode($_POST['email']));
$phone=$_POST['phone'];
// Image upload
define ("MAX_SIZE","100");
function getExtension($str) {
$i = strrpos($str,".");
if (!$i) { return ""; }
$l = strlen($str) - $i;
$ext = substr($str,$i+1,$l);
return $ext;
}
// Make sure file is an image
if (($_FILES["file"]["type"] != NULL)
&& ($_FILES["file"]["type"] != "image/gif")
&& ($_FILES["file"]["type"] != "image/png")
&& ($_FILES["file"]["type"] != "image/jpeg")
&& ($_FILES["file"]["type"] != "image/jpg")
&& ($_FILES["file"]["type"] != "image/pjpeg")){
header('location: wrong_format_fail.php');
exit();
}
// If it is continue
else {
$image = $_FILES['file']['name'];
$uploadedfile = $_FILES['file']['tmp_name'];
$fileSize = $_FILES['file']['size'];
$fileType = $_FILES['file']['type'];
// Change the extension to lower case
if($image) {
$filename = stripslashes($_FILES['file']['name']);
$extension = getExtension($filename);
$extension = strtolower($extension);
// Get image size
$size=filesize($_FILES['file']['tmp_name']);
// Check to see if it's too big
if ($size > MAX_SIZE*2048) {
echo "<script type='text/javascript'>";
echo "alert('Image is too large! Please shrink it and try again.')";
echo "</script>";
}
// Check image type and then create jpeg of it
if($extension=="jpg" || $extension=="jpeg" || $extension=="pjpeg") {
$uploadedfile = $_FILES['file']['tmp_name'];
$src = imagecreatefromjpeg($uploadedfile);
}
else if($extension=="png") {
$uploadedfile = $_FILES['file']['tmp_name'];
$src = imagecreatefrompng($uploadedfile);
}
else {
$src = imagecreatefromgif($uploadedfile);
}
// Percentages used to change image size
$percent = 0.5;
$percent1 = 0.25;
list($width,$height)=getimagesize($uploadedfile);
// Original
$newwidth=$width;
$newheight=($height/$width)*$newwidth;
$tmp=imagecreatetruecolor($newwidth,$newheight);
// 1/2 the size
$newwidth1=$width*$percent;
$newheight1=($height/$width)*$newwidth1;
$tmp1=imagecreatetruecolor($newwidth1,$newheight1);
// 1/4 of the size
$newwidth2=$width*$percent1;
$newheight2=($height/$width)*$newwidth2;
$tmp2=imagecreatetruecolor($newwidth2,$newheight2);
// Copy the images with the new $width & $height
imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
imagecopyresampled($tmp1,$src,0,0,0,0,$newwidth1,$newheight1,$width,$height);
imagecopyresampled($tmp2,$src,0,0,0,0,$newwidth2,$newheight2,$width,$height);
// Filepath to images
$filePath = "images/uploaded/";
$filePathSmall = "images/uploaded/small/";
$filePathThumb = "images/uploaded/thumbnail/";
// Create a filenames that won't be repeated
$fileName = rand()."_".$title.".jpg";
$fileNameSmall = $newheight1."x".$newheight1."_".$fileName.".jpg";
$fileNameThumb = $newheight2."x".$newheight2."_".$fileName.".jpg";
// Send the Images to the correct place
imagejpeg($tmp,$filePath.$filename,100);
imagejpeg($tmp1,$filePathSmall.$fileNameSmall,100);
imagejpeg($tmp2,$filePathThumb.$fileNameThumb,100);
// Destroy temporary images
imagedestroy($src);
imagedestroy($tmp);
imagedestroy($tmp1);
imagedestroy($tmp2);
}
}
// Insert values into database
$sql = "INSERT INTO posting
(title, description, address, city, start_date, start_time, end_time, start_date1, start_time1, end_time1,
start_date2, start_time2, end_time2, start_date3, start_time3, end_time3,
image, filenamesmall, filenamethumb, type, size, path,
class, city_wide, email, phone)
VALUES
('$title', '$description', '$address', '$city', '$start_date', '$start_time', '$end_time', '$start_date1', '$start_time1', '$end_time1',
'$start_date2', '$start_time2', '$end_time2', '$start_date3', '$start_time3', '$end_time3',
'$fileName', '$fileNameSmall', '$fileNameThumb', '$fileType', '$fileSize', '$filePath',
'$class', '$city_wide', '$email', '$phone')";
// Execute the query
$result=mysql_query($sql);
// If successful
if($result){
echo "<script type='text/javascript'>";
echo "var yes = confirm('Thank you for posting your sale to Rummage City! Would you like to leave feedback?');";
echo "if(yes){window.location='feedback.php';}";
echo "else {window.location='listings.php';}";
echo "</script>";
}
else {
echo "<script type='text/javascript'>";
echo "alert('Something went wrong')";
echo "</script>";
}
}
[/php]