| | |
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 |
advanced ajax apache api array basics beginner binary broken cakephp check checkbox class cms code combobox cookies cron curl database date datepart display dynamic echo email error file files folder form forms function functions google head href htaccess html image include includingmysecondfileinthechain insert integration ip java javascript job joomla js limit link login loop mail menu mlm multiple mysql oop parse password paypal pdf php problem procedure query radio random recursion regex remote script search server sessions smarty smash sms soap source space sql stored syntax system table traffic tutorial unicode update upload url validator variable video web xml youtube





