Jump to content

PHP gives me filenames of files--but then tells me the files don't exist? HUH?


doni49

Recommended Posts

PHP does have read/write permissions to this folder and the files.  Another PHP script CREATED most of the files that are in this folder.

 

My head hurts!

 

if (is_dir($dir)) {
   //get the directory handle
   if ($dh = opendir($dir)) {
       //get one filename at a time
       while (($file = readdir($dh)) !== false) {
           $files[] = $file;
           chdir($dir);
           //make sure $file is not a directory or the error_log file
           if (!is_dir($file)  && !eregi ("^error_log.*$",$file)){
               copy($file, $dest . $file);
           }
       }
   }
}
echo "<br>\nFiles:<pre>";
print_r ($files);
echo "</pre>";

 

The above code outputs the following.

 

Warning: copy(/home/donirela/.SALearn/ham/cur/tadfasafasf:2,S) [function.copy]: failed to open stream: No such file or directory in /home/donirela/public_html/SALearn.php on line 25

 

Files:

 

Array

(

    [0] => .

    [1] => ..

    [2] => error_log

    [3] => tadfasafasf:2,S

)

Link to comment
Share on other sites

UPDATE:  I've continued to investigate.  It SEEMS to be copying the file--but then gives that error message saying that it COULDN'T copy it.  The file SAYS 0kb but then has a BUNCH of text in it when I edit the file.

Link to comment
Share on other sites

I'm on a hosted account w/CPanel access.  I've found that after running the script, there is a file in the destination location of the same name as the original file.

 

CP has a 'File Manager'.  It tells me the file is 0kb (copy)--I'll have to double check on the size of the original file.  When I click on 'Edit File' in the file mgr, it opens the file and the text that was in the original file IS there.

 

So I guess the current Qs are:

 

1) why is PHP telling me that it couldn't copy is it DID copy? 

 

2) why is CP showing 0kb when the file DOES have text in it?  (This last one might be better directed at CPanel).

Link to comment
Share on other sites

Well--I just checked CP's file manager.  It shows the original as 0kb as well as the copy.

 

Anyone have any ideas why it would tell me it was unable to copy the file when it did?  It's also creating an error_log file in the source folder.

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.