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

  • SEARCH
  • Home
  • 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 7050921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:12:08+00:00 2026-05-28T03:12:08+00:00

My program is supposed to create a folder for the uploaded images on the

  • 0

My program is supposed to create a folder for the uploaded images on the directory but gives this warning:

mkdir() [function.mkdir]: File exists in C:\XAMP\xampp\htdocs\gallery\uploader3.php on line 26

Here is the code:

<html>
<head>
<title> Sample1  - File Upload on Directory </title>
</head>
<body>
<div align="center">
<form action="uploader3.php" method="post" enctype="multipart/form-data" >
    <input type="hidden" name="MAX_FILE_SIZE" value="100000" />
        Create an Album (limited to 10 images): <br />
    <input type="file" name="uploadedfile[]"  /><br />
    <input type="file" name="uploadedfile[]"  /><br />
    <input type="file" name="uploadedfile[]"  /><br />
    <input type="file" name="uploadedfile[]"  /><br />
    <input type="file" name="uploadedfile[]"  /><br />
    <input type="file" name="uploadedfile[]"  /><br />
    <input type="file" name="uploadedfile[]"  /><br />
    <input type="file" name="uploadedfile[]"  /><br />
    <input type="file" name="uploadedfile[]"  /><br />
    <input type="file" name="uploadedfile[]"  /><br />
    <br />
    <input type="submit" value="Upload File"   />
</form>
</div>
<?php 
$target_path = "uploads1/";
if(!mkdir($target_path))
{
    die('Failed to create folders...');
}
else
{
    for($count = 0; $count < count($_FILES['uploadedfile']); $count++)
    {
        $target_path = $target_path . basename( $_FILES['uploadedfile']['name'][$count]); 

        if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'][$count], $target_path)) 
        {
            echo "The file ".  basename( $_FILES['uploadedfile']['name'][$count]). 
        " has been uploaded";
        } 
        else{
        echo "There was an error uploading the file, please try again!";
        }
    }
}

?>
</body>
</html>
  • 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-05-28T03:12:09+00:00Added an answer on May 28, 2026 at 3:12 am

    Modify your codes below:

    if(!mkdir($target_path))
    {
        die('Failed to create folders...');
    }
    

    to:

    if(!file_exist($target_path)) {
      if(!mkdir($target_path))
      {
          die('Failed to create folders...');
      }
    }
    

    That will check the folder first, if it’s already exist, no need to create it again.

    for your 2nd question, you need to store the uploaded image names to somewhere ( i guess DB is a good choice), Then, you can show them anywhere you want.
    Or you can use below codes to search in folder and display them:

    $image_files = glob("uploads1/*.jpg");
    foreach($image_files as $img) {
        echo "<img src='".$img."' /><br/>";
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am supposed to write a program that gets some PNG images from the
As a school assignment, I am supposed to create a program in C# that
This program is supposed to calculate the number of degrees below 60 on a
Basically the program is supposed to create a round table of executives, with a
I'm writing a program that is supposed to create chains of numbers and see
For my homework assignment, I'm supposed to create an ATM/Teller program which stores users
The program is supposed to accept telnet connections on port 8888 and then send
I have a program that is supposed to interact with a web server and
I am supposed to write a program in JavaScript to find all the anagrams
I have a program for the iPhone that is supposed to be doing intelligent

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.