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 7511483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T23:33:34+00:00 2026-05-29T23:33:34+00:00

Here is what I have so far, I apologize for the length but this

  • 0

Here is what I have so far, I apologize for the length but this gives you the complete picture:

if(count($_FILES['file']['name'])) 
            {

            foreach ($_FILES['file']['name'] as $key => $file)
                {



            $add="../uploads/photogallery/".time().'_'.$file;

            $storefile = time().'_'.$file;

                             echo $storefile; // THIS WORKS

                if(move_uploaded_file ($_FILES['file']['tmp_name'][$key],$add))
                {

                                     // CODE IS NOT GETTING INTO THIS AREA,

                    //database insert here

                    //mysql_query ($query);

                    echo '<meta http-equiv="refresh" content="0;url=?VIEW=PHOTOADD&photo_added">';
                }
                else
                {
                    echo '<meta http-equiv="refresh" content="0;url=?VIEW=PHOTOADD&photo_not_added">';
                }

            ///////// Start the thumbnail generation//////////////

            $n_width=150;          // Fix the width of the thumb nail images
            $n_height=150;         // Fix the height of the thumb nail imaage

            $tsrc="../uploads/photogallery/thumbnail/".time().'_'.$file;

            if (!($_FILES['file']['type'][$key] =="image/pjpeg" || $_FILES['file']['type'][$key] == "image/gif" || $_FILES['file']['type'][$key] == "image/png") || ($_FILES["file"]["type"][$key] == "image/jpeg") && ($_FILES["file"]["size"][$key] < 2097152))
                {
                    echo '<meta http-equiv="refresh" content="0;url=?VIEW=PHOTOADD&photo_requirements_not_met">';
                }

            /////////////////////////////////////////////// Starting of GIF thumb nail creation///////////

            if (@$_FILES['file']['type'][$key] =="image/gif")
                {
                    $im=ImageCreateFromGIF($add);

                    $width=ImageSx($im);              // Original picture width is stored
                    $height=ImageSy($im);                  // Original picture height is stored

                    $newimage=imagecreatetruecolor($n_width,$n_height);

                    imageCopyResized($newimage,$im,0,0,0,0,$n_width,$n_height,$width,$height);

                    if (function_exists("imagegif")) 
                    {
                        Header("Content-type: image/gif");
                        ImageGIF($newimage,$tsrc);
                    }

                    elseif (function_exists("imagejpeg")) 
                    {
                        Header("Content-type: image/jpeg");
                        ImageJPEG($newimage,$tsrc);
                    }
                    elseif (function_exists("imagepng")) 
                    {
                        Header("Content-type: image/png");
                        ImagePNG($newimage,$tsrc);
                    }
                }

            ////////////// starting of JPG thumb nail creation//////////

            if ($_FILES['file']['type'][$key] == "image/pjpeg")
                {
                    $im=ImageCreateFromJPEG($add); 

                    $width=ImageSx($im);              // Original picture width is stored
                    $height=ImageSy($im);             // Original picture height is stored

                    $newimage=imagecreatetruecolor($n_width,$n_height);                 

                    imageCopyResized($newimage,$im,0,0,0,0,$n_width,$n_height,$width,$height);

                    ImageJpeg($newimage,$tsrc);
                }

            if ($_FILES['file']['type'][$key] == "image/png")
                {
                    $im=ImageCreateFromPNG($add); 

                    $width=ImageSx($im);              // Original picture width is stored
                    $height=ImageSy($im);             // Original picture height is stored

                    $newimage=imagecreatetruecolor($n_width,$n_height);                 

                    imageCopyResized($newimage,$im,0,0,0,0,$n_width,$n_height,$width,$height);

                    ImagePNG($newimage,$tsrc);
                }
            }
        }
        else
        {
            echo '<meta http-equiv="refresh" content="0;url=?VIEW=PHOTOADD&photo_requirements_not_met">';
        }

And here is the HTML portion of the form:

<input class="input" name="file[]" type="file" id="file" multiple=""/>

Yes the form has the correct enctype. See my comments in the code above where it says THIS WORKS and CODE IS NOT..etc. That is where my issue is. It’s getting inside the for each loop part since I can echo $storefile and get the correct filename with the time stamp, but it won’t get into the if (move_uploaded_..) portion and skips to the echo photo requirements not met portion.

Any help would be greatly appreciated. I am not getting any PHP or mysql errors.

  • 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-29T23:33:35+00:00Added an answer on May 29, 2026 at 11:33 pm

    use foreach ($_FILES['file']['name'] as $key => $file) as for loop

    $_FILES['file']['tmp_name'][$key] in if clause

    for reference

    For instance, assume that the filenames /home/test/review.html and
    /home/test/xwp.out are submitted. In this case,
    $_FILES[‘userfile’][‘name’][0] would contain the value review.html,
    and $_FILES[‘userfile’][‘name’]1 would contain the value xwp.out.
    Similarly, $_FILES[‘userfile’][‘size’][0] would contain review.html’s
    file size, and so forth.

    $_FILES[‘userfile’][‘name’][0], $_FILES[‘userfile’][‘tmp_name’][0],
    $_FILES[‘userfile’][‘size’][0], and $_FILES[‘userfile’][‘type’][0] are
    also set.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I really wonder why this question hasn't popped up here so far. I have
have tried a few different approaches to this but with no success so far.
Here's what I have so far: def is_ordered(collection): if isinstance(collection, set): return False if
Here is what I have so far : def mergesort[T <: Ordered[T]](elements : List[T])
http://pastebin.com/mYk8M038 here is what I have so far... I think it may be something
I'm using the Firefox Add-on Builder and here is what I have so far:
I'm a total newb to LINQ. Here is the code I have so far:
Here is what I have tried thus far: > cd /Applications/MAMP/bin/php5/bin/ > ./pear channel-discover
I have a feeling that this probably is not possible using strictly CSS, but,
I apologize for this, and I am sure it's a very rookie question... but

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.