• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 90
  • Last Modified:

scandir() not reads all files

Hello everyone,
I get an issue with the scandir() function in PHP.
In my script i employ an scandir() function, which scans a file, these file was generate by php and the files in there was generated by an upload script. move().
When I scan this file, I get not always spent all existing files.
Sometines they are not complete, but sometimes even.

  $file = "upload/server/php/files/" . $id."/";
             $handle =  opendir($file);
            $allfiles = scandir($file);
            print_r($allfiles);                          // These Variable isn't complete with all dirs and files
            zipping($file, $allfiles,$id);

Open in new window

0
obcc-srs
Asked:
obcc-srs
  • 2
1 Solution
 
Julian HansenCommented:
If I understand your question correctly
You have a FOLDER to which files are uploaded
You want to get all the files in this folder and ZIP them up.
When you use scandir - not all the files in the folder are being seen.

Can you give an example of what the output from line 4 looks like and what is missing from that list?
0
 
Ray PaseurCommented:
Well, this is a data-dependent problem and we do not have your data, so we cannot test the answers we give you -- you will have to do that.  

In order to answer we need to know what files are not found.  What are their names?  What permissions are set on the directories and files?  We also need to see the values of the variables, for example, what is in $file?

A modern alternative to the scandir() function is available in the SPL directory iterator.  You might try experimenting with these side-by-side to see if the more up-to-date extension gives you better results.
0
 
obcc-srsAuthor Commented:
As Example:

I Uppladed these Files: adminer.php and Activities.png.
scanddir indetify thumblr file, and Activities.png
// Thumblr is a file generated by php script.

Does not adminer.php
Another Example:
Uploaded:
ABO.gif and nice.jpg

scandir indedity: ABO.gif and nice.jpg also complete all
In an other Example the same Files are nice.jpg and Abo.jpg

There only founf nice.jpg  and thumblr but not Abo.gif.

Or Input: SoapUI.exe and SampleVideo.mp4
Output: These Files without thumblr // these File is generate in every Uploaded File But is not packaged
0
 
Julian HansenCommented:
Please post results of print_r($files); statement (line 4 of your example) - exactly as it appears in your browser.

Also, post a screengrab of the folder in question showing the files that are there.
1

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now