Solved

scandir() not reads all files

Posted on 2016-10-17
4
66 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 57

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 57

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

728 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