|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Hi,
I have some PHP code that creates a PNG image. All I want is to have a button that saves the created image to the user's hard disk. I need this since a lot of people do not know that they can right click on the image and save it. Thansk beforehand. Mark |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
"hol" <contact7@hol.gr> wrote in message news:fjmgkg$gsa$1@newsmaster.pub.dc.hol.net... > Hi, > > I have some PHP code that creates a PNG image. > All I want is to have a button that saves the created image to the user's > hard disk. > I need this since a lot of people do not know that they can right click on > the image and save it. an href with a specific target can call your php png image creation script simply when the user clicks the link. all your creation script need do is set the content-type and content-disposition. your browser takes care of asking the user if they want to open it or save it. > Thansk beforehand. you're welcome afterhand. |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
Thanks Steve,
What you suggest is a simple solution to my problem. The dissadvantage of the method is that the php script that creates the image, takes quite some time to execute since it collects data from a rather big database. Therefore I was thinking that since the image has been already created, I wouldn't have to recreate it. Any ideas? Ï "Steve" <no.one@example.com> Ýãñáøå óôï ìÞíõìá news:ZNz7j.31$%91.30@newsfe05.lga... > > "hol" <contact7@hol.gr> wrote in message > news:fjmgkg$gsa$1@newsmaster.pub.dc.hol.net... >> Hi, >> >> I have some PHP code that creates a PNG image. >> All I want is to have a button that saves the created image to the user's >> hard disk. >> I need this since a lot of people do not know that they can right click >> on the image and save it. > > an href with a specific target can call your php png image creation script > simply when the user clicks the link. all your creation script need do is > set the content-type and content-disposition. your browser takes care of > asking the user if they want to open it or save it. > >> Thansk beforehand. > > you're welcome afterhand. > |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
"hol" <contact7@hol.gr> wrote in message news:fjmi9b$gsa$2@newsmaster.pub.dc.hol.net... > Thanks Steve, > > What you suggest is a simple solution to my problem. > The dissadvantage of the method is that the php script that creates the > image, takes quite some time to execute since it collects data from a > rather big database. > Therefore I was thinking that since the image has been already created, I > wouldn't have to recreate it. > > Any ideas? i have to start then by stating the obvious...create the image once (based on your constraints...big db, etc.), save it to the *server's* hd, show it in the browser...surrounding the image in an href that points to the image on the server and make the href have a specific target. how you decide to manage the archival or deletion of the images on the server would be up to you. if there's something more complex you had in mind, let me know. |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
hol wrote:
> Thanks Steve, > > What you suggest is a simple solution to my problem. > The dissadvantage of the method is that the php script that creates the > image, takes quite some time to execute since it collects data from a rather > big database. > Therefore I was thinking that since the image has been already created, I > wouldn't have to recreate it. 1. Check if the file is on the local hard drive with file_exists() 2a. if not, create the image and save it to hard drive 2b. load the already created image into your script 3. spit out the image with the proper headers. This is how we do at my work, first time any user enter a page, the script generates the previews in the right size, this first load usually takes longer time, but any visit after that goes quite fast as no need to create the images. -- //Aho |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
Thanks for your J.O. Aho & Steve
Unfortunatelly this solution does not really work for me. To explain the situation better let me tell you that the user of this site has the opportunity to collect specific data from a huge database, and create some diagrams on the spot. The number of different diagrams is unlimited since there are many different parameters. That is why I cannot store those images on the server. I just need the users to be able to store an image that has been created there and then on their hard disk. Thank you for your valuable . ? "J.O. Aho" <user@example.net> ?????? ??? ?????? news:5s837tF181015U1@mid.individual.net... > hol wrote: >> Thanks Steve, >> >> What you suggest is a simple solution to my problem. >> The dissadvantage of the method is that the php script that creates the >> image, takes quite some time to execute since it collects data from a >> rather >> big database. >> Therefore I was thinking that since the image has been already created, I >> wouldn't have to recreate it. > > 1. Check if the file is on the local hard drive with file_exists() > > 2a. if not, create the image and save it to hard drive > 2b. load the already created image into your script > > 3. spit out the image with the proper headers. > > > This is how we do at my work, first time any user enter a page, the script > generates the previews in the right size, this first load usually takes > longer > time, but any visit after that goes quite fast as no need to create the > images. > > -- > > //Aho |
|
|
|
#7 |
|
Messages: n/a
Hébergeur: |
"hol" <contact7@hol.gr> wrote in message news:fjmo52$gsa$3@newsmaster.pub.dc.hol.net... > Thanks for your J.O. Aho & Steve > > Unfortunatelly this solution does not really work for me. > > To explain the situation better let me tell you that the user of this site > has the opportunity to collect specific data from a huge database, and > create some diagrams on the spot. > The number of different diagrams is unlimited since there are many > different parameters. That is why I cannot store those images on the > server. please explain. you can certainly store those images on the server and associate them with that user and the diagram he's generating. i don't see the problem here. > I just need the users to be able to store an image that has been created > there and then on their hard disk. the way in which aho and i have described is your only way to do this unless you choose to dynamically generate it more than once. the only other alternative would be to tell them specifically to right-click the image and choose save. you cannot do this for them using javascript or some other scripting language on the client side...i.e. their browser. so, you're stuck managing your options on the server. best of luck. |
|
|
|
#8 |
|
Messages: n/a
Hébergeur: |
On Dec 11, 11:24 am, "hol" <conta...@hol.gr> wrote:
> > The number of different diagrams is unlimited since there > are many different parameters. That is why I cannot store > those images on the server. Of course you can... Just name the files uniquely (say, using uniqid()) and keep deleting image files that are more than an hour (day, week, month) old. > I just need the users to be able to store an image that > has been created there and then on their hard disk. So here are your choices, (1) regenerate (which you don't want to do, because it takes time), or (2) save to the server's file system (which you don't want to do, because it takes disk space). There is no third option. Cheers, NC |
|
![]() |
| Outils de la discussion | |
|
|