| | |
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
Views: 2944 | Replies: 6
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class cms code cron curl database date directory display download dynamic ebooks echo email error file files folder form forms function functions google href htaccess html image include insert integration ip java javascript joomla jquery js limit link login loop mail mediawiki menu methods mlm mod_rewrite multiple mysql oop parse paypal pdf php problem query radio random recursion regex remote script search select server sessions sms soap source space speed sql stored structure subdomain syntax system table tutorial update updates upload url validation validator variable video web xml youtube





