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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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