jakebur01 Posted October 11, 2011 Share Posted October 11, 2011 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); Quote Link to comment https://forums.phpfreaks.com/topic/248909-write-file-to-network-drive/ Share on other sites More sharing options...
ManiacDan Posted October 11, 2011 Share Posted October 11, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/248909-write-file-to-network-drive/#findComment-1278338 Share on other sites More sharing options...
AbraCadaver Posted October 11, 2011 Share Posted October 11, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/248909-write-file-to-network-drive/#findComment-1278345 Share on other sites More sharing options...
jakebur01 Posted October 11, 2011 Author Share Posted October 11, 2011 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"; Quote Link to comment https://forums.phpfreaks.com/topic/248909-write-file-to-network-drive/#findComment-1278352 Share on other sites More sharing options...
AbraCadaver Posted October 11, 2011 Share Posted October 11, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/248909-write-file-to-network-drive/#findComment-1278356 Share on other sites More sharing options...
jakebur01 Posted October 11, 2011 Author Share Posted October 11, 2011 Using just the sharename worked! Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/248909-write-file-to-network-drive/#findComment-1278384 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.