| | |
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 |
.htaccess action ajax apache api array auto beginner binary bounce broken cakephp checkbox class cms code cron curl database date display dynamic echo email error errorlog file files folder form format forms function functions google href htaccess html image include insert integration interactive ip java javascript joomla limit link login loop mail malfunctioning masterthesis menu mlm mod_rewrite multiple mysql nodes oop paypal pdf php popup problem query radio ram random recursion reference regex remote return script search server sessions sms soap source space sql syntax system table tutorial unset update upload url validation validator variable video web websitecontactform xml youtube





