[PHP] Opening files....
Hello, I want to open files in a directory other than the Document root via HTTP on the client machine. How do i do it ? For example I have .JPG files in a directory /toallocate on my Server running FC2, Apache2, Mysql, PHP5. I allocated certain .JPG files to some users and moved them to a directory called /allocated and logged the absolute path in a Mysql Table with the user name. Now we know the username and the files allocated to him and their path. When the user logs into his account, he should see the file allocated to him and they should be clickable links so that when he clicks them they open in the required software. I tried just providing links to their absolute path but then it doesnt work because Apache looks for them relative to the Document Root. Please some one help me in this concern, I will wait for a quick reply. Also, Is there a way that I can force the .JPG files to open in a particular software ? thanks in advance Vaibhav Sibal -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Opening files....
Hello, I want to open files in a directory other than the Document root via HTTP on the client machine. How do i do it ? Yes, it's possible Just supose you have the images under /var/images/. This won't be acceded by apache since it's out of documentroot. You can set up some alias to /var/images For example alias /images/ /var/images/ The problem is, that most servers don't let users access directories outside the DocumentRoot of the customers VirtualHost. Also, if you can read that directory, you can create a path images in your documentroot, and create a .htaccess file like this: ErrorDocument 404 image.php In image.php you catch the referrer with $_SERVER['http_referrer'] and display the image sending the header img/jpeg Also, Is there a way that I can force the .JPG files to open in a particular software ? No. Best, Guillermo Rauch. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Opening Files via PHP
Anyone familiar with PHP AND MYSQL WEB DEVELOPMENT, 2nd edition, by Luke Welling and Laura Thomson? And perhaps working on the Macintosh-UNIX side of things via OS X.whatever? If so, I ask for your indulgence and assistance. Following advice given me a coupla weeks ago--on this very list, I believe--I've bought it to ground myself firmly in PHP and MySQL both, before moving on to my platform- and HTML editor-specific choices. In this case--not surprising, given my second question above--I'm learning the UNIX brand on the Macintosh OS X.whatever side of things to eventually work with this Dreamweaver MX I've heard is so convenient with which to work. That is, once I've properly learned the PHP/HTML underpinnings. And so I've gotten as far as chapter two running the book's code, before a problem's occurred that I can't get a handle on. It's obviously because I'm new to the world of UNIX and its file conventions. A file to read and write to has been provided on the book's CD. I've copied this file, named oders.txt, in a folder (directory) on my hard drive, the path which runs like so: [hard drive name]/Library/WebServer/Documents/orders/orders.txt. And the code the book uses to write to this file is: // open file for appending $fp = fopen($DOCUMENT_ROOT/../orders/orders.txt, 'a'); flock($fp, LOCK_EX); if (!$fp) { echo 'pstrong Your order could not be processed at this time. ' .'Please try again later./strong/p/body/html'; exit; } fwrite($fp, $outputstring); flock($fp, LOCK_UN); fclose($fp); echo 'pOrder written./p'; Unfortunately, my browser--Netscape 7.02--gives the following in response to that code: Warning: fopen(/Library/WebServer/Documents/../orders/orders.txt) [function.fopen]: failed to create stream: No such file or directory in /Users/stephent/Sites/php_mysql_web_dev/chapter_02/processorder.php on line 63 Warning: flock(): supplied argument is not a valid stream resource in /Users/[name I use]/Sites/php_mysql_web_dev/chapter_02/processorder.php on line 65 Your order could not be processed at this time. Please try again later. Can someone point out what I need to do here to make this work? Thank you. Stephen Tiano -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Opening Files via PHP
Stephen Tiano wrote: And the code the book uses to write to this file is: // open file for appending $fp = fopen($DOCUMENT_ROOT/../orders/orders.txt, 'a'); This is what is in the book, you need to change the path to suit your setup. Or move the file, it seems moving ./orders/ directory one directory up should solve your problem. Unfortunately, my browser--Netscape 7.02--gives the following in response to that code: Warning: fopen(/Library/WebServer/Documents/../orders/orders.txt) [function.fopen]: failed to create stream: No such file or directory in /Users/stephent/Sites/php_mysql_web_dev/chapter_02/processorder.php on line 63 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Opening Files via PHP
* Thus wrote Stephen Tiano ([EMAIL PROTECTED]): A file to read and write to has been provided on the book's CD. I've copied this file, named oders.txt, in a folder (directory) on my hard drive, the path which runs like so: [hard drive name]/Library/WebServer/Documents/orders/orders.txt. And the code the book uses to write to this file is: // open file for appending $fp = fopen($DOCUMENT_ROOT/../orders/orders.txt, 'a'); echo $DOCUMENT_ROOT; You'll see exactly where php is looking for to open the file. You can either adjust the location where you copied the file or modify the code to adjust for where you put it. I would suggest the former in case other examples use the same structure, you wont have to deal with this when trying to learn the examples. flock($fp, LOCK_EX); I'm not sure why the book doesn't try to lock the file after the check for valid file handle. This is what causes the second error. Unfortunately, my browser--Netscape 7.02--gives the following in response to that code: Warning: fopen(/Library/WebServer/Documents/../orders/orders.txt) [function.fopen]: failed to create stream: No such file or directory in /Users/stephent/Sites/php_mysql_web_dev/chapter_02/processorder.php on line 63 Warning: flock(): supplied argument is not a valid stream resource in /Users/[name I use]/Sites/php_mysql_web_dev/chapter_02/processorder.php on line 65 Curt -- My PHP key is worn out PHP List stats since 1997: http://zirzow.dyndns.org/html/mlists/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] opening files
How do you open a text file and put all the contents into a variable like $filecontent? Joseph -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] opening files
-Original Message- From: Joseph Bannon [mailto:[EMAIL PROTECTED]] Sent: Tuesday, May 01, 2001 2:33 PM To: PHP (E-mail) Subject: [PHP] opening files How do you open a text file and put all the contents into a variable like $filecontent? You use some combination of the commands presented at http://www.php.net/manual/en/ref.filesystem.php If you're just wanting something quick and simple, you might find the file() function particularly useful. --- Mark Roedel ([EMAIL PROTECTED]) || There cannot be a crisis next week. Systems Programmer / WebMaster || My schedule is already full. LeTourneau University ||-- Henry Kissinger -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]