Jump to content


Photo

Uploading and downloading images


  • Please log in to reply
2 replies to this topic

#1 jbille

jbille
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 18 October 2006 - 08:42 PM

I have a form which uploads the following information into mysql:
name
number
description
price
image

However I am having trouble uploading the image and then viewing the image on a page with the rest of these results.  I've looked but have not been able to find any help on this.  Can anyone give me suggestions.

#2 simcoweb

simcoweb
  • Members
  • PipPipPip
  • Advanced Member
  • 1,102 posts
  • LocationCA

Posted 18 October 2006 - 08:59 PM

Please post your code for the image upload.

#3 jbille

jbille
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 18 October 2006 - 09:46 PM

$name = $_POST['name'];
	$number = $_POST['number'];
	$price = $_POST['price'];
	$order = $_POST['order'];
	$category = $_POST['category'];
	$description = $_POST['description'];
	$picture = $_POST['picture'];
	
	
	if((empty($name)) || (empty($number)) || (empty($price)) 
	 || (empty($category)) || (empty($description)))
	{
		echo "Please <a href=\"addproduct.html\">go back</a> and fill in the following information: ";
		if(empty($name)) echo ("Product Name");
		if(empty($number)) echo ("Product Number");
		if(empty($price)) echo ("Product Price");
		if(empty($category)) echo ("Category must be picked");
		if(empty($description)) echo ("Product Description");
		exit(1);
	}
 
	$data = addslashes(fread(fopen($picture, "r"), filesize($picture)));
		
	$link = mysql_connect(localhost, $user, $pass);
if (!$link) {
   die('Not connected : ' . mysql_error());
}
	mysql_select_db($dbname, $link) or die("Unable to select database");
	$query ="INSERT INTO products (category, name, number, price, description, picture) VALUES ('$category', '$name', '$number', '$price', '$description', '$data')";
	mysql_query($query) or die('Error, query failed, Call Jimmy (330)268-9271');
	mysql_close($link);





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users