Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8309557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T19:09:26+00:00 2026-06-08T19:09:26+00:00

I’m simply trying to loop through a folder of images and put them in

  • 0

I’m simply trying to loop through a folder of images and put them in an Amazon S3 bucket. I just can’t figure out why it doesn’t like the DATA part of the PUTFILE function.

If I try:

$res = $s3 -> putFile("test-bucket/".$entry);

It creates a blank file (0 bytes) in the bucket, so I know it’s connecting OK, and the filenames are correct also. I’ve also tried looping through the folders files and echoing the filenames to the screen, without using the Zend S3 function, which proved this page can access the files behind root.

The documentation regarding this function says:

putFile($path, $object, $meta) puts the content of the file in $path
into the object named $object.

The optional $meta argument is the same as for putObject. If the
content type is omitted, it will be guessed basing on the source file
name.

This is what I’ve tried:

if ($handle = opendir('d:/web-library-photos/temp-previews')) {

    $loopCounter = 0;
    while (false !== ($entry = readdir($handle))) {
        ///
        $loopCounter = $loopCounter + 1;
        if ($loopCounter < 3) { // for test purposes only
            $localPath = "d:/web-library-photos/temp-previews/".$entry;
            $s3 = new Zend_Service_Amazon_S3($aws_access_key_id, $aws_s3_secret);
            $res = $s3 -> putFile($localPath, "test-bucket/".$entry);
            echo "Success for ".$entry.": " . ($res ? 'Yes' : 'No') . "<br>";
        }
        ///
    }

    closedir($handle);
}

This particular “try” yields the error:

Cannot read file d:/web-library-photos/temp-previews/.' in C:\Inetpub\vhosts\.....thispage.php

So I thought I would try file_get_contents() and readfile() but still no luck!

Please, please, put me straight on this one – it’s driving me round the bend.

UPDATE

Right, I have a clue what’s wrong but not how to solve it.

If I simply do this:

if ($handle = opendir('d:/web-library-photos/temp-previews')) {
    while (false !== ($entry = readdir($handle))) {
    echo $entry."<BR>";
    }
    closedir($handle);
}

I get a . and a .. at the beginning of my results, which obviously can’t be read as filenames!! What is going on here, how do I get around it?

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T19:09:29+00:00Added an answer on June 8, 2026 at 7:09 pm

    Try to append this in while (false !== ($entry = readdir($handle)))

    while (false !== ($entry = readdir($handle))) {  
        if($entry == "." || $entry == "..") continue;
        /* other codes */
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to loop through a bunch of documents I have to put
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have a jquery bug and I've been looking for hours now, I can't
I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.