Jump to content

Scandir Retrurning No Directory Found


Grazza

Recommended Posts

I made a simple little code to scan a directory of .doc files and then put all of the information into an sql database but scandir() keeps failing claming the directory doesn't exist.

 

Code is as follows (only the boring sql connection clipped off):

$directory = "aa/";

$date = date("m.d.y");

 

$files = scandir('$directory');

foreach($files as $file) {

$fh = fopen($file, 'r');

$content = fread($fh, filesize($file));

fclose($fh);

 

mysql_query("INSERT INTO database (`filename`,`date`,`directory`,`content`) VALUES ('$file','$date','aa','$content')");

}

 

The folder aa is in the same folder as I am running the script from, I have tried using the full path from root with the same results.

 

Error as shown: Warning: scandir($directory): failed to open dir: No such file or directory

 

Any help would be much appreciated.

Link to comment
https://forums.phpfreaks.com/topic/272615-scandir-retrurning-no-directory-found/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.