File To Blob Corruption

File To Blob Corruption

am 15.11.2009 02:39:20 von Don Wieland

Hello,

I am trying to create an UPLOAD page to Update a Images and PDFs into
a BLOB field in mySQL. The image keeps getting corrupted (it draws a
portion of the image and the rest is GRAY) We tried it with Safari and
Firefox with bad results.

Here is the form that is used to browse and select the file.





Upload Thumbnail image


Please select the thumbnail image, then press Upload.

enctype="multipart/form-data">
Select Thumbnail:



onclick="saveDialog('uploadImage','img','jpg');"> value="Cancel" onclick="cancelDialog('uploadImage','img')">




Here is the QUERY to upload the image (saveDialog.php):

if($_POST['obj'] == "uploadImage") {
$file = $db->real_escape_string(file_get_contents($_FILES['img']
['tmp_name']));
$db->query("UPDATE Areas SET Image = '$file'") or die("1".$db->error);

Has anyone else ever run into this type of UPDATE error with images
and PDF? We really need to get this dealt with ASAP.

Thanks!

Don Wieland
D W D a t a C o n c e p t s
~~~~~~~~~~~~~~~~~~~~~~~~~
donw@dwdataconcepts.com
Direct Line - (949) 305-2771

Integrated data solutions to fit your business needs.

Need assistance in dialing in your FileMaker solution? Check out our
Developer Support Plan at:
http://www.dwdataconcepts.com/DevSup.html

Appointment 1.0v9 - Powerful Appointment Scheduling for FileMaker Pro
9 or higher
http://www.appointment10.com

For a quick overview -
http://www.appointment10.com/Appt10_Promo/Overview.html


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: File To Blob Corruption

am 15.11.2009 04:43:31 von geek.de

--0016363b7984614973047860b254
Content-Type: text/plain; charset=UTF-8

Hi, Could it have something to do with an eof character being encoded or
something like that? Do you really need to store the files in the DB? It
uses more processing power if stored in the DB because on retrieval, you
have to unescape the string and return it. Modern filesystems are optimised
better for files than databases and storing a filename and returning the
contents is easier to implement than retrieving it from the DB...

http://forums.codewalkers.com/php-applications-45/upload-ima ge-file-to-mysql-as-blob-849194.html

++Tim Hinnerk Heuer++

http://www.ihostnz.com


2009/11/15 Don Wieland

> Hello,
>
> I am trying to create an UPLOAD page to Update a Images and PDFs into a
> BLOB field in mySQL. The image keeps getting corrupted (it draws a portion
> of the image and the rest is GRAY) We tried it with Safari and Firefox with
> bad results.
>
> Here is the form that is used to browse and select the file.
>
>
>


>

>

>
Upload Thumbnail image

>
> Please select the thumbnail image, then press Upload.
> > style="margin-top:14px;margin-bottom:14px;text-align:center; width:100%">
>
> enctype="multipart/form-data">
> Select Thumbnail: > accept="image/jpeg" />

>
>
> > onclick="saveDialog('uploadImage','img','jpg');"> > value="Cancel" onclick="cancelDialog('uploadImage','img')">
>
>

>
>
> Here is the QUERY to upload the image (saveDialog.php):
>
> if($_POST['obj'] == "uploadImage") {
> $file =
> $db->real_escape_string(file_get_contents($_FILES['img']['tm p_name']));
> $db->query("UPDATE Areas SET Image = '$file'") or die("1".$db->error);
>
> Has anyone else ever run into this type of UPDATE error with images and
> PDF? We really need to get this dealt with ASAP.
>
> Thanks!
>
> Don Wieland
> D W D a t a C o n c e p t s
> ~~~~~~~~~~~~~~~~~~~~~~~~~
> donw@dwdataconcepts.com
> Direct Line - (949) 305-2771
>
> Integrated data solutions to fit your business needs.
>
> Need assistance in dialing in your FileMaker solution? Check out our
> Developer Support Plan at:
> http://www.dwdataconcepts.com/DevSup.html
>
> Appointment 1.0v9 - Powerful Appointment Scheduling for FileMaker Pro 9 or
> higher
> http://www.appointment10.com
>
> For a quick overview -
> http://www.appointment10.com/Appt10_Promo/Overview.html
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--0016363b7984614973047860b254--

Re: File To Blob Corruption

am 15.11.2009 11:17:14 von Ashley Sheridan

--=-bpQCB7flJnEzAscevUSh
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

On Sun, 2009-11-15 at 16:43 +1300, German Geek wrote:

> Hi, Could it have something to do with an eof character being encoded or
> something like that? Do you really need to store the files in the DB? It
> uses more processing power if stored in the DB because on retrieval, you
> have to unescape the string and return it. Modern filesystems are optimised
> better for files than databases and storing a filename and returning the
> contents is easier to implement than retrieving it from the DB...
>
> http://forums.codewalkers.com/php-applications-45/upload-ima ge-file-to-mysql-as-blob-849194.html
>
> ++Tim Hinnerk Heuer++
>
> http://www.ihostnz.com
>
>
> 2009/11/15 Don Wieland
>
> > Hello,
> >
> > I am trying to create an UPLOAD page to Update a Images and PDFs into a
> > BLOB field in mySQL. The image keeps getting corrupted (it draws a portion
> > of the image and the rest is GRAY) We tried it with Safari and Firefox with
> > bad results.
> >
> > Here is the form that is used to browse and select the file.
> >
> >
> >


> >

> >

> >
Upload Thumbnail image

> >
> > Please select the thumbnail image, then press Upload.
> > > > style="margin-top:14px;margin-bottom:14px;text-align:center; width:100%">
> >
> > enctype="multipart/form-data">
> > Select Thumbnail: > > accept="image/jpeg" />

> >
> >
> > > > onclick="saveDialog('uploadImage','img','jpg');"> > > value="Cancel" onclick="cancelDialog('uploadImage','img')">
> >
> >

> >
> >
> > Here is the QUERY to upload the image (saveDialog.php):
> >
> > if($_POST['obj'] == "uploadImage") {
> > $file =
> > $db->real_escape_string(file_get_contents($_FILES['img']['tm p_name']));
> > $db->query("UPDATE Areas SET Image = '$file'") or die("1".$db->error);
> >
> > Has anyone else ever run into this type of UPDATE error with images and
> > PDF? We really need to get this dealt with ASAP.
> >
> > Thanks!
> >
> > Don Wieland
> > D W D a t a C o n c e p t s
> > ~~~~~~~~~~~~~~~~~~~~~~~~~
> > donw@dwdataconcepts.com
> > Direct Line - (949) 305-2771
> >
> > Integrated data solutions to fit your business needs.
> >
> > Need assistance in dialing in your FileMaker solution? Check out our
> > Developer Support Plan at:
> > http://www.dwdataconcepts.com/DevSup.html
> >
> > Appointment 1.0v9 - Powerful Appointment Scheduling for FileMaker Pro 9 or
> > higher
> > http://www.appointment10.com
> >
> > For a quick overview -
> > http://www.appointment10.com/Appt10_Promo/Overview.html
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >


Like someone mentioned on the link you posted; storing the images in the
database does offer a layer of security, as database access is far
easier to control than file access.

Thanks,
Ash
http://www.ashleysheridan.co.uk



--=-bpQCB7flJnEzAscevUSh--

Re: File To Blob Corruption

am 15.11.2009 22:14:14 von news.NOSPAM.0ixbtqKe

On Sat, 14 Nov 2009 17:39:20 -0800, Don Wieland wrote:

> Hello,
>
> I am trying to create an UPLOAD page to Update a Images and PDFs into
> a BLOB field in mySQL. The image keeps getting corrupted (it draws a
> portion of the image and the rest is GRAY) We tried it with Safari and
> Firefox with bad results.
>
> Here is the QUERY to upload the image (saveDialog.php):
>
> if($_POST['obj'] == "uploadImage") {
> $file = $db->real_escape_string(file_get_contents($_FILES['img']
> ['tmp_name']));
> $db->query("UPDATE Areas SET Image = '$file'") or die("1".$db->error);

Random ideas:

* Select the image from the database and compare it to $file.
Are they identical?
* Run a hex dump on the images before and after upload.
What is the difference?


/Nisse

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: File To Blob Corruption

am 16.11.2009 14:05:01 von TedD

At 10:17 AM +0000 11/15/09, Ashley Sheridan wrote:
>
>Like someone mentioned on the link you posted; storing the images in the
>database does offer a layer of security, as database access is far
>easier to control than file access.
>
>Thanks,
>Ash
>http://www.ashleysheridan.co.uk

It also offers ease of moving, You don't have to move both database
and file system to a different server, just the database.
Additionally, the file paths are always correct -- just reference the
database. So, there are upsides to storing images in a database.

I haven't read a single MySQL/PHP book (dozens) that claims storing
images in a database is a bad idea.

Cheers,

tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: File To Blob Corruption

am 16.11.2009 14:06:11 von TedD

At 10:14 PM +0100 11/15/09, Nisse =?utf-8?Q?Engström?= wrote:
>
>* Run a hex dump on the images before and after upload.
> What is the difference?
>
>/Nisse

That's the best idea.

That way you know how the file has been changed.

Cheers,

tedd

--
-------
http://sperling.com http://ancientstones.com http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: File To Blob Corruption

am 16.11.2009 15:10:01 von Phpster

On Mon, Nov 16, 2009 at 8:05 AM, tedd wrote:
> At 10:17 AM +0000 11/15/09, Ashley Sheridan wrote:
>>
>> Like someone mentioned on the link you posted; storing the images in the
>> database does offer a layer of security, as database access is far
>> easier to control than file access.
>>
>> Thanks,
>> Ash
>> http://www.ashleysheridan.co.uk
>
> It also offers ease of moving, You don't have to move both database and f=
ile
> system to a different server, just the database. Additionally, the file
> paths are always correct -- just reference the database. So, there are
> upsides to storing images in a database.
>
> I haven't read a single MySQL/PHP book (dozens) that claims storing image=
s
> in a database is a bad idea.
>
> Cheers,
>
> tedd
> --
> -------
> http://sperling.com =A0http://ancientstones.com =A0http://earthstones.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Well, I can tell you that mysql really starts to have issues when the
image table gets up to around 12Gb in size. And if you look at larger
DBs like oracle the like, internally they store a pointer in the table
and the image elsewhere.

--=20

Bastien

Cat, the other other white meat

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php