0
votes

I think it is something simple that has to do with my paths, because when I just create the files in the current folder, everything works. That being said, I am pretty unfamiliar with fopen(), fwrite(), and fclose(). The errors I am getting are (I think once the first one is fixed, the rest will work, too):

Warning: fopen(test/b/shipLabels/1_8154_0.pdf) [function.fopen]: failed to open stream: No such file or directory in /public_html/test/b/lib/FedEx/ShipWebServiceClient/Ground/Domestic MPS/ShipWebServiceClient.php5 on line 116

Warning: fwrite() expects parameter 1 to be resource, boolean given in /public_html/test/b/lib/FedEx/ShipWebServiceClient/Ground/Domestic MPS/ShipWebServiceClient.php5 on line 117

Warning: fclose() expects parameter 1 to be resource, boolean given in /public_Html/test/b/lib/FedEx/ShipWebServiceClient/Ground/Domestic MPS/ShipWebServiceClient.php5 on line 118

The lines that references are:

 $fp = fopen(SHIP_MASTERLABEL, 'wb');
     fwrite($fp, ($masterResponse->CompletedShipmentDetail->CompletedPackageDetails->Label->Parts->Image));
 fclose($fp);

I define SHIP_MASTERLABEL using this:

define('SHIP_MASTERLABEL', 'test/b/shipLabels/'.$clientId.'_'.$invoiceId.'_0.pdf');

In this case, $clientId=1, $invoiceId=8154. For the most part, this syntax has been provided by the FedEx docs.

Thanks so much for your help!

1
Your Link is relativ; Your Code Looks here: /test/b/lib/FedEx/ShipWebServiceClient/Ground/Domestic MPS/test/b/shipLabels/1_8154_0.pdf And this file is Probably not existingj_s_stack
@j_s_stack so my next problem is that when I try to go up a few directories, my error gets replaced with Warning: fopen(../../../../../../test/b/shipLabels/1_8154_0.pdf) [function.fopen]: failed to open stream: No such file or directory in /home/guysandd/public_html/test/b/lib/FedEx/ShipWebServiceClient/Ground/Domestic MPS/ShipWebServiceClient.php5 on line 116. Is there some way to correctly go up a path in the define() function?radleybobins
The best way is to use an absolute Link I thinkj_s_stack
@j_s_stack, okay thanks, i'll mark the absolute path answer correct when I am able toradleybobins
@j_s_stack I appreciate you taking the time to help out beginners like me with dumb little questions!radleybobins

1 Answers

2
votes

you 'd better use the absolute path ,and use the const like DIR FILE etc...