how deposit a picture to MYSQL database

Reply

Join Date: Jun 2006
Posts: 26
Reputation: shaocpa is an unknown quantity at this point 
Solved Threads: 0
shaocpa's Avatar
shaocpa shaocpa is offline Offline
Light Poster

how deposit a picture to MYSQL database

 
0
  #1
Jun 28th, 2006
how deposit a picture to MYSQL database
below is the code :

<?php
$id=$_POST['id'];

$photo=$_POST['pic'];
if ($photo<>""){
$fp=fopen($photo,"r");
$data=addslashes(fread($fp,filesize($photo)));
}

$sql="insert into product(id,pic) values('$id','$data')";
mysql_query($sql,$conn) or die ("插入数据失败: ".mysql_error());
?>

but always unsuccessful! why? plz help me!
Colin Shao
Reply With Quote Quick reply to this message  
Join Date: Jan 2004
Posts: 17
Reputation: noppid is an unknown quantity at this point 
Solved Threads: 0
noppid noppid is offline Offline
Newbie Poster

Re: how deposit a picture to MYSQL database

 
0
  #2
Jun 29th, 2006
Look up the super global $_FILES['xxx'] on php.net. Your file and it's info are in it. Assuming your form is correct.
Last edited by noppid; Jun 29th, 2006 at 5:44 pm.
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 32
Reputation: BlazingWolf is an unknown quantity at this point 
Solved Threads: 1
BlazingWolf BlazingWolf is offline Offline
Light Poster

Re: how deposit a picture to MYSQL database

 
0
  #3
Jul 1st, 2006
Not only that you must store the picture as Binary or Blob data type, and you need more than just the data, such as extension(to deteremine what compression is used), and the size.

I suggest you search on google, there are plent of great articles on the net for upload images and stuff to databases.
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 26
Reputation: shaocpa is an unknown quantity at this point 
Solved Threads: 0
shaocpa's Avatar
shaocpa shaocpa is offline Offline
Light Poster

Re: how deposit a picture to MYSQL database

 
0
  #4
Jul 3rd, 2006
thanks a lot

when i test this code on my own computer,it is successful.
but when i upload this code to special PHP space it is unsuccessful
why? are you have the same functional code?

pls help me!!!!
Colin Shao
Reply With Quote Quick reply to this message  
Join Date: Jan 2004
Posts: 17
Reputation: noppid is an unknown quantity at this point 
Solved Threads: 0
noppid noppid is offline Offline
Newbie Poster

Re: how deposit a picture to MYSQL database

 
0
  #5
Jul 4th, 2006
Home test beds are useless for development IMO. For that matter, only one server for development can bite ya in the code.

You need to test and develop on a real server and test on more then one server for the best results.
Reply With Quote Quick reply to this message  
Join Date: Jun 2006
Posts: 26
Reputation: shaocpa is an unknown quantity at this point 
Solved Threads: 0
shaocpa's Avatar
shaocpa shaocpa is offline Offline
Light Poster

Re: how deposit a picture to MYSQL database

 
0
  #6
Jul 5th, 2006
thanks a lot noppid !!

i have resolved my question !

" Look up the super global $_FILES['xxx'] on php.net.
Your file and it's info are in it. Assuming your form is correct.
"

your this word enlighten me!!
thanks!
Colin Shao
Reply With Quote Quick reply to this message  
Join Date: Jan 2004
Posts: 17
Reputation: noppid is an unknown quantity at this point 
Solved Threads: 0
noppid noppid is offline Offline
Newbie Poster

Re: how deposit a picture to MYSQL database

 
0
  #7
Jul 10th, 2006
It's good to hear you were able to use the reference and solve your problem.

Great work!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the PHP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC