PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old May 29th, 2004, 04:44 PM
dungnm dungnm is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 1 dungnm User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Insert Image into Database, big problem, need help !!!

Hello all,

I get Image filename, data, type, size in the file InsertImage.php. This image is called from a form, which is in another file called Upload.inc. But the problem is when I used this command in InsertImage.php

$Img_data = addslashes(fread(fopen($Imgfile, "r"), filesize($Imgfile)));

with the $Imgfile is the file called from the form of Upload.inc.
Then I used SQL query to insert all the information, including
Image data ( value: $Img_data) into the database as following:
$result=MYSQL_QUERY("insert into user (Img_data, Imgname, Imgsize, Imgtype) values ('$Img_data', '$Imgname', '$Imgsize', '$Imgtype'") ;

The result is all the informations are inserted as well, except the value of $Img_data' always returns wrong size of BLOB data link this (BLOB-57Bytes), while the real size of the Image is 230Kbytes.

Normally, if the Form that contains the Image file name is in the same file then every thing goes well, but here, the the FORM containing Image is in another file

I am goind around this problem my self for 2 weeks already, but can not solve it. Can somebody help me ?

Thanks a lot
NMDung
Attached Files
File Type: zip php files.zip (4.1 KB, 457 views)

Reply With Quote
  #2  
Old May 29th, 2004, 04:51 PM
digitalamit digitalamit is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: New Delhi, India
Posts: 19 digitalamit User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to digitalamit Send a message via AIM to digitalamit Send a message via Yahoo to digitalamit
Try using the addcslashes along with / instead of addslashes.

Personally I think you should base64_encode the data. But be advised this would slow things a bit

HTH!

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > Insert Image into Database, big problem, need help !!!


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT