Jump to content

write file to network drive


jakebur01

Recommended Posts

Is there a way to write a file to a directory on my network?

 

I tried creating a shortcut called automated and pointed it to the network path.  I also set up a virtual directory called automated in IIS and still could not make it work. I gave it read and write permissions.

 

error

Warning: fopen(C:\Inetpub\wwwroot\dompdf\automated\resource.pdf) [function.fopen]: failed to open stream: No such file or directory in C:\Inetpub\wwwroot\date.php on line 69

 

Warning: fwrite() expects parameter 1 to be resource, boolean given in C:\Inetpub\wwwroot\date.php on line 70

 

Warning: fclose() expects parameter 1 to be resource, boolean given in C:\Inetpub\wwwroot\date.php on line 71

 

code

require_once("dompdf/dompdf_config.inc.php");

$html =
  '<html><body>'.
  '<p>Put your html here, or generate it with your favourite '.
  'templating system.</p>'.
  '</body></html>';

$dompdf = new DOMPDF();
$dompdf->load_html($html);
$dompdf->render(); 
$pdfoutput = $dompdf->output(); 
$filename = "C:\\Inetpub\\wwwroot\\dompdf\\automated\\resource.pdf"; 
$fp = fopen($filename, "a"); 
fwrite($fp, $pdfoutput); 
fclose($fp); 

Link to comment
Share on other sites

You can't append to a PDF file anyway, so you may want to abandon this whole line.

 

To answer your direct question: I don't believe IIS can go through virtual directories.  See if you can view the files using glob() or exec() just as a test.

 

Disclaimer:  I haven't worked on an IIS server in 8 years.

 

-Dan

Link to comment
Share on other sites

Disclaimer:  I haven't worked on an IIS server in 8 years.

 

Me neither, but in addition, by directory on your network I assume you mean mapped drive as opposed to UNC?  If so, the actual IIS user would need access to the location and would need to map this drive.  Maybe at the beginning of your script.

Link to comment
Share on other sites

hmm..  I tried mapping a drive under M:\ pointing it to the sharename, but I got the same error.

 

Warning: fopen(M:\resource.pdf) [function.fopen]: failed to open stream: No such file or directory in C:\Inetpub\wwwroot\date.php on line 69

 

$filename = "M:\\resource.pdf";

Link to comment
Share on other sites

The IIS user needs to map the drive.  So something like this maybe at the top of your script:

 

exec('net use M: \\computername\path\to\dir');

//or just try:

$filename = '\\computername\path\to\dir\resource.pdf';

 

It's been a while and I didn't really use PHP under IIS.  ut regardless, the IIS user nomally 'iuser_somethingcryptic' needs to have read/write access to that location.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.