Getting image data as a variable

This is a discussion on Getting image data as a variable within the alt.comp.lang.php forums, part of the PHP Programming Forums category; The problem lies in that I want to use database explicity for putting up images on a blogsite (i don'...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-16-2006
Gnutt Halvordsson
 
Posts: n/a
Default Getting image data as a variable

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
Reply With Quote
  #2 (permalink)  
Old 01-17-2006
d
 
Posts: n/a
Default Re: Getting image data as a variable

"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 :))


Reply With Quote
  #3 (permalink)  
Old 01-18-2006
Norman Peelman
 
Posts: n/a
Default Re: Getting image data as a variable

"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


Reply With Quote
  #4 (permalink)  
Old 01-23-2006
Gnutt Halvordsson
 
Posts: n/a
Default Re: Getting image data as a variable

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...
>> 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
>
>

Reply With Quote
  #5 (permalink)  
Old 01-23-2006
Gnutt Halvordsson
 
Posts: n/a
Default Re: Getting image data as a variable

> 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...
>> 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 :))
>
>

Reply With Quote
Reply


Thread Tools
Display Modes

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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 11:37 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0