For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > January 2006 > Getting image data as a variable









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Getting image data as a variable
Gnutt Halvordsson

2006-01-16, 9:55 pm

The problem lies in that I want to use database explicity for putting up
images on a blogsite (i don't want to use the filesystem what-so-ever)
(mostly to save myself from having issues with duplicate filenames, and
when I delete one, both goes.)

Image is loaded via a web-form, and are to be resized. Currently I save
the images on a folder which everyone has write and execution-access to.

Images are resized via the imagecreatetruecolor() and
imagecopyresampled(), and then written to the filesystem. After that
read into variables, which in their turn is written into the database.

Is there any way for me the skip the filesystem-bit?

Help much appriciated.
//Gnutt
d

2006-01-17, 6:57 pm

"Gnutt Halvordsson" <gnutt@shell.linux.se> wrote in message
news:RCVyf.154118$dP1.512537@newsc.telia.net...
> The problem lies in that I want to use database explicity for putting up
> images on a blogsite (i don't want to use the filesystem what-so-ever)
> (mostly to save myself from having issues with duplicate filenames, and
> when I delete one, both goes.)
>
> Image is loaded via a web-form, and are to be resized. Currently I save
> the images on a folder which everyone has write and execution-access to.
>
> Images are resized via the imagecreatetruecolor() and
> imagecopyresampled(), and then written to the filesystem. After that read
> into variables, which in their turn is written into the database.
>
> Is there any way for me the skip the filesystem-bit?


Yes - don't write them to the filesystem. You can use imagejpeg to return
the actual image data as a string, which you can then put in the database.

> Help much appriciated.
> //Gnutt


(this isn't a lecture but an offer of help: making so much work for each
and every request is not a great idea - if you can do the work once when you
add/remove images, your web server would thank you :) I'm not having a go,
I just don't see the benefit - it's pretty easy to make scripts reliable
enough to overcome missing images (should that ever happen) and duplicate
filenames... if you tell me what your actual concerns are, maybe I can help?
I worked at a company that had several hundred gigabytes of images, all
indexed by database, so I have a bit of experience with this, not that I'm
saying you don't :))


Norman Peelman

2006-01-18, 7:56 am

"Gnutt Halvordsson" <gnutt@shell.linux.se> wrote in message
news:RCVyf.154118$dP1.512537@newsc.telia.net...
> The problem lies in that I want to use database explicity for putting up
> images on a blogsite (i don't want to use the filesystem what-so-ever)
> (mostly to save myself from having issues with duplicate filenames, and
> when I delete one, both goes.)
>
> Image is loaded via a web-form, and are to be resized. Currently I save
> the images on a folder which everyone has write and execution-access to.
>
> Images are resized via the imagecreatetruecolor() and
> imagecopyresampled(), and then written to the filesystem. After that
> read into variables, which in their turn is written into the database.
>
> Is there any way for me the skip the filesystem-bit?
>
> Help much appriciated.
> //Gnutt


Yes, you can work directly on the $_FILE array as once the image is
uploaded it is already on the filesystem in a temporary folder.

Norm


--
FREE Avatar hosting at www.easyavatar.com


Gnutt Halvordsson

2006-01-23, 3:55 am

Sure I can do this, but I want to resize images before saving them into
the database, therefore, working with the $_FILE does not work.

Any other ideas.

Norman Peelman skrev:
> "Gnutt Halvordsson" <gnutt@shell.linux.se> wrote in message
> news:RCVyf.154118$dP1.512537@newsc.telia.net...
>
> Yes, you can work directly on the $_FILE array as once the image is
> uploaded it is already on the filesystem in a temporary folder.
>
> Norm
>
>

Gnutt Halvordsson

2006-01-23, 3:55 am

> Yes - don't write them to the filesystem. You can use imagejpeg to
return
> the actual image data as a string, which you can then put in the

database.
How? I've tried this a numerous times, and currently I write the images
to a temporary file, and then reads the data from that file (and puts it
in the database).

--

The work is done when uploading a image to the server, and then saved
into the database. This is to make it much easier for me to backup the
site. Since I don't have local access to the site, and still want to be
able to write bakcupscripts, so that I have a backup of the site every
now and then. This way, all I need to do is keep a working copy of the
code, and then take a backup of the database every now and then in order
to keep my backup up-to-date.

d skrev:
> "Gnutt Halvordsson" <gnutt@shell.linux.se> wrote in message
> news:RCVyf.154118$dP1.512537@newsc.telia.net...
>
> Yes - don't write them to the filesystem. You can use imagejpeg to return
> the actual image data as a string, which you can then put in the database.
>
>
> (this isn't a lecture but an offer of help: making so much work for each
> and every request is not a great idea - if you can do the work once when you
> add/remove images, your web server would thank you :) I'm not having a go,
> I just don't see the benefit - it's pretty easy to make scripts reliable
> enough to overcome missing images (should that ever happen) and duplicate
> filenames... if you tell me what your actual concerns are, maybe I can help?
> I worked at a company that had several hundred gigabytes of images, all
> indexed by database, so I have a bit of experience with this, not that I'm
> saying you don't :))
>
>

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com