Solved

scandir() not reads all files

Posted on 2016-10-17
4
26 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
  • 2
4 Comments
 
LVL 51

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 108

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 51

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
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 tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

760 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now