Forum Moderators: coopster

Message Too Old, No Replies

saving a decoded php file

saving a decoded php file

         

goldencrown

10:29 pm on Feb 16, 2005 (gmt 0)

10+ Year Member



i have been shearching online to see if any one has done this before and it is looking like no. or at least been posted....
what i am doing is getting a pregenrated label in either php,tif,jpeg or gif...(currently it is pdf) and what i want to do is get the image save the image with a unique file name and save the path into mysql db and save the file on to my server. the image is incoded with base 64. so far i have decoded the image so this is were i am at

$LabelImage = "$DeliveryConfirmationLabel[1]";

echo base64_decode($LabelImage);

when i echo the file apears in a pdf viewer..

so far i have tryed to save the file but i just can't seem to get it to work.... here is my code

$LabelImage = "$DeliveryConfirmationLabel[1]";

$decodeimage = base64_decode($LabelImage);
this so far i know works...
and then something like this

$data = $decodeimage;
header('Content-type: application/pdf');
header('Content-disposition: inline; filename=decodedimage.pdf');
header('Content-length: ' . strlen($data));

then something like this

fwrite($data, decodedimage.pdf)

I don't have a good grasp of what is going on...
i am having a hard time with fwrite() all the examples i read have me open a file with

$filepointer = fopen("nameoffile.txt","w")

and then it has me close the file with
fclose($filepointer)

or fwrite

but they are making the assumption that i have a saved file that i am working with... which i don't

hakre

1:21 am on Feb 17, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



welcome to webmasterworld, goldencrown!

you're using fwrite() [de2.php.net] falsely. next to

$data
it needs a filepointer as parameter. you get one by using fopen() on a filename. fwrite is binary safe, so after fopen, fwrite and fclose your file should be readable.