0

I am using ue UPS shipment API ...

<LabelSpecification>
    <LabelStockSize>
        <Height>4</Height>
        <Width>6</Width>
    </LabelStockSize>
    <LabelPrintMethod>
        <Code>EPL</Code>
        <Description>epl file</Description>
    </LabelPrintMethod>
    <HTTPUserAgent>Mozilla/4.5</HTTPUserAgent>
    <LabelImageFormat>
        <Code>GIF</Code>
        <Description>gif</Description>
    </LabelImageFormat>
    </LabelSpecification>

. . .

it's return raw format of image like STgsQSwwMDEKSTgsQSwwMDEKT0QKcTc5NQpRMTYwMCwyNApTMgpEMTAKSkYKTgpaVApiMTMsNDI5LE0sIjAxNSw4NDAsMTk0MDYsMDAwMCxbKT4eMDEdOTYxWjk0NjM4NzYzHVVQU04dNDRBQTE1HjA3L1RNRjItODIlKVFNKE1VQloyMDcpWEoyK0JORUlZOEorXCJcDVEgLBxZJDhEXA1cDR4EIgpBMTcsNywwLDIsMSwxLE4sIlRFU1QiCkExNywyNCwwLDIsMSwxLE4sIjExMS0xMTEtMTExMSIKQTE3LDQxLDAsMiwxLDEsTiwiMTE1MCBGSVJTVCBBVkUiCkExNyw1OCwwLDIsMSwxLE4sIktJTkcgT0YgUFJVU1NJQSAgUEEgMTk0MDYiCkE2MiwxNjQAAAAP/////....

I want to know how can I save the image to my pc and to show it on the web page.

Aziz Shaikh
  • 16,245
  • 11
  • 62
  • 79
test
  • 17
  • 1
  • 5

2 Answers2

1

I succeed in php, using fopen and fwrite to create a gif file,such as

$file=fopen("temp.gif","w");
fwrite($file,base64_decode("the encoded string..."));

this will get a gif file,then you can put it on the web.Remenber to chown the folder where you save the gif file with apache:apache.

Wenhuang Lin
  • 214
  • 2
  • 8
0

Not familiar with UPS API but USPS returns label data base64 encoded. Maybe try and use the function base64_decode and then file_put_contents to save to disk.

Ghassan Idriss
  • 2,120
  • 20
  • 16
  • i am already use this thing file_put_contents($time.'.gif',base64_decode($author[1][0])); or file_put_contents($time.'.epl',base64_decode($author[1][0])); image size show 0 bytes. but image not open. – test Jul 18 '12 at 07:08
  • You should debug and see what $author[1][0] is outputting. – Ghassan Idriss Jul 18 '12 at 07:22
  • output is right like STgsQSwwMDEKSTgsQSwwMDEKT0QKcTc5NQpRMTYwMCwyNApTMgpEMTAKSkYKTgpaVApiMTMsNDI5LE0sIjAxNSw4NDAsMTk0MDYsMDAwMCxbKT4eMDEdOTYxWjk0NjM4NzYzHVVQU04dNDRBQTE1HjA3L1RNRjItODIlKVFNKE1VQloyMDcpWEoyK0JORUlZOEorXCJcDVEgLBxZJDhEXA1cDR4EIgpBMTcsNywwLDIsMSwxLE4sIlRFU1QiCkExNywyNCwwLDIsMSwxLE4sIjExMS0xMTEtMTExMSIKQTE3LDQxLDAsMiwxLDEsTiwiMTE1MCBGSVJTVCBBVkUiCkExNyw1OCwwLDIsMSwxLE4sIktJTkcgT0YgUFJVU1NJQSAgUEEgMTk0MDYiCkE2MiwxNjQAAAAP/////.... but how to show in webpage ? – test Jul 18 '12 at 07:27
  • You should always add to your question what you did already so it is more clear what your question specifically is. This website is no wonder machine you only need to throw some broadly worded questions into to get something out. – hakre Aug 06 '12 at 10:17