Solved

scandir() not reads all files

Posted on 2016-10-17
4
59 Views
Last Modified: 2016-11-07
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
Comment
Question by:obcc-srs
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 56

Expert Comment

by:Julian Hansen
ID: 41846695
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
 
LVL 110

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 41846699
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
 

Author Comment

by:obcc-srs
ID: 41846787
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
 
LVL 56

Expert Comment

by:Julian Hansen
ID: 41846832
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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question