note 52035 rejected from function.fopen by betz

From: Date: Tue, 19 Apr 2005 16:12:26 +0000
Subject: note 52035 rejected from function.fopen by betz
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-88218@lists.php.net to get a copy of this message
Note Submitter: cecil at repolift dot com ---- I use fopen to open a file from my local drive in read-only mode. The filename is supplied thru a html form. I use phpdev5 as my development web server. When I access the page from my pc, the file is opened. However, if I access the page from the website or from another pc, i get an error "No such file or directory". Below is the code. untitled-3.php ------------- <form name="form1" enctype="multipart/form-data" method="post" action="Untitled-5.php"> <input name="upfile" type="file" id="upfile"> <br> <input type="submit" name="Submit" value="Submit" onClick="document.form1.filename.value=document.form1.upfile.value"> <input type="hidden" name="filename"> </form> untitled-5.php ------------- <? $a=ini_get('safe_mode'); echo "<br>Safe mode is ".$a; $a=ini_get('open_basedir'); echo "<br>Open basedir is ".$a; $a=ini_get('allow_url_fopen'); echo "<br>allow_url_fopen is ".$a; $a=ini_set('allow_url_fopen','0'); $a=ini_get('allow_url_fopen'); echo "<br>allow_url_fopen is ".$a; if(isset($_POST['filename'])){echo "<br>filename is set, name is ".$_POST['filename'];$fnm=$_POST['filename'];}else{echo "<br>filename not set";} if(!fopen($fnm, "r")){echo "<br>$fnm could not be opened";}else{echo "<br>$fnm was opened";} ?> The foll. is the output when run from my pc: Safe mode is 0 Open basedir is allow_url_fopen is 1 allow_url_fopen is 0 filename is set, name is D:\\test1.txt D:\\test1.txt was opened The foll. is the output when run from my the website: Safe mode is Open basedir is allow_url_fopen is 1 allow_url_fopen is 0 filename is set, name is D:\\test1.txt D:\\test1.txt could not be opened Thanks in advance.

« previous php.notes (#88218) next »