[PHP] Help needed / failed to open stream: Permission denied
Hello, Trying to read a binary file in MySQL database, i have the following error : Warning: fopen(./) [function.fopen]: failed to open stream: Permission denied in d:\...\download.php on line 57 This is line 57 $file_handle = fopen(./ . $file_name, r); and my function function db_download_file($dbname, $file, $idreunion) { //Sélectionne la base de données mysql_select_db($dbname); //Requête SQL $select = SELECT . $file . FROM inter_vertaaldienst WHERE id_reunion = ' . $idreunion . '; //Exécution de la requête $file_records = @mysql_query($select); //En cas d'erreur, on affiche un message if (!$file_records){echo('pErreur :' . mysql_error().'p');} //Autrement, on affiche le fichier else{ if($file_record = mysql_fetch_array($file_records)){ $file_handle = fopen(./ . $file_name, r); $file_bytes = $file_record[0]; fwrite($file_handle, $file_bytes, strlen($file_bytes)); $return_value = ./ . $file_name; } } return($return_value); } Thank for your help. Ndagi -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Help needed / failed to open stream: Permission denied
Hello, Trying to read a binary file in MySQL database, i have the following error : Warning: fopen(./) [function.fopen]: failed to open stream: Permission denied in d:\...\download.php on line 57 This is line 57 $file_handle = fopen(./ . $file_name, r); and my function function db_download_file($dbname, $file, $idreunion) { //Sélectionne la base de données mysql_select_db($dbname); //Requête SQL $select = SELECT . $file . FROM inter_vertaaldienst WHERE id_reunion = ' . $idreunion . '; //Exécution de la requête $file_records = @mysql_query($select); //En cas d'erreur, on affiche un message if (!$file_records){echo('pErreur :' . mysql_error().'p');} //Autrement, on affiche le fichier else{ if($file_record = mysql_fetch_array($file_records)){ $file_handle = fopen(./ . $file_name, r); $file_bytes = $file_record[0]; fwrite($file_handle, $file_bytes, strlen($file_bytes)); $return_value = ./ . $file_name; } } return($return_value); } Place an: echo ./ . $file_name; ...just above line 57 and make sure that the filename is what you expect it to be. If it is, make sure the user the webserver is running as has permissions sufficient to open the file for reading. You could, as a test, temporarily chmod 777 the file to rule out permission issues. JM -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Help needed / failed to open stream: Permission denied
Ndagi Mutiri wrote: Hello, I can't be of any help here but couldn't help noticing that th OP (Ndagi) is dealing with dutch language DB entities and comments/output in french and code (vars etc) in english bet that can be a PITA :-) Trying to read a binary file in MySQL database, i have the following error : Warning: fopen(./) [function.fopen]: failed to open stream: Permission denied in d:\...\download.php on line 57 This is line 57 $file_handle = fopen(./ . $file_name, r); and my function function db_download_file($dbname, $file, $idreunion) { //Sélectionne la base de données mysql_select_db($dbname); //Requête SQL $select = SELECT . $file . FROM inter_vertaaldienst WHERE id_reunion = ' . $idreunion . '; //Exécution de la requête $file_records = @mysql_query($select); //En cas d'erreur, on affiche un message if (!$file_records){echo('pErreur :' . mysql_error().'p');} //Autrement, on affiche le fichier else{ if($file_record = mysql_fetch_array($file_records)){ $file_handle = fopen(./ . $file_name, r); $file_bytes = $file_record[0]; fwrite($file_handle, $file_bytes, strlen($file_bytes)); $return_value = ./ . $file_name; } } return($return_value); } Thank for your help. Ndagi -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php