| | |
how deposit a picture to MYSQL database
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
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!
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
•
•
Join Date: Feb 2006
Posts: 32
Reputation:
Solved Threads: 1
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.
I suggest you search on google, there are plent of great articles on the net for upload images and stuff to databases.
![]() |
Similar Threads
Other Threads in the PHP Forum
- Previous Thread: URL Masking in PHP
- Next Thread: Two domains on the same account
| Thread Tools | Search this Thread |
301 apache api array autosuggest beginner binary broken cakephp checkbox class cms code compression cron curl data database date display dropdownlist dynamic echo email eregi error execution file files folder form forms function functions google href htaccess html httppost if...loop image include insert ip javascript joomla jquery key library limit link links login mail md5 menu mlm multiple mysql mysql_real_escape_string oop paypal pdf pdfdownload php phpvotingscript problem query radio random recursion remote screen script search searchbox server session sessions sms sorting source space sql syntax system table tutorial update upload url validator variable video volume votedown web website youtube zend





