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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T19:11:08+00:00 2026-06-04T19:11:08+00:00

I need to upload some files (images but it doesn’t matter) using jquery and

  • 0

I need to upload some files (images but it doesn’t matter) using jquery and php.
I find a jquery plugin plugin to make multiple upload file, http://www.fyneworks.com/jquery/multiple-file-upload/ . So i have these two input:

<script type="text/javascript" language="javascript">                  
      $(function(){                    
        $('#immagini').MultiFile({       
        list: '#lista-immagini'          
      });           
      });            
</script>     
<input type="file" name="immagini[]" id="immagini" accept="gif|jpg|tiff" maxlength="10" />  

<script type="text/javascript" language="javascript">                  
      $(function(){                    
        $('#plan').MultiFile({       
        list: '#lista-plan'          
      });           
      });            
</script>     
<input type="file" name="plan[]" id="plan" accept="gif|jpg|tiff" maxlength="10" />  

And php file that is called from the form is:

$files = array();
$fdata = $_FILES['immagini'];


if(isset($_FILES['immagini']))
if(is_array($fdata['name']) && !empty($fdata['name'])){
        for($i=0;$i<count($fdata['name']);++$i){
            $files[]=array(
                'name'    =>$fdata['name'][$i],
                'tmp_name'=>$fdata['tmp_name'][$i],
                'type' => $fdata['type'][$i],
                'size' => $fdata['size'][$i],
                'error' => $fdata['error'][$i],
        );
        }

        foreach($files as $file){
            $tmpName = $file['tmp_name'];
            $fp = fopen($tmpName, 'r');
            $immagine = fread($fp, filesize($tmpName));
            $immagine = addslashes($immagine);
            $DB->query('INSERT INTO immagini(id_annuncio, immagine) values('.$_GET['id'].', "'.$immagine.'")');
            fclose($fp);
        }
}


    $files = array();
$fdata = $_FILES['plan'];

    if(isset($_FILES['plan']))
if(is_array($fdata['name']) && !empty($fdata['name'])){
        for($i=0;$i<count($fdata['name']);++$i){
            $files[]=array(
                'name'    =>$fdata['name'][$i],
                'tmp_name'=>$fdata['tmp_name'][$i],
                'type' => $fdata['type'][$i],
                'size' => $fdata['size'][$i],
                'error' => $fdata['error'][$i],
            );
        }
        foreach($files as $file){
            $tmpName = $file['tmp_name'];         
            $fp = fopen($tmpName, 'r');
            $immagine = fread($fp, filesize($tmpName));
            $immagine = addslashes($immagine);
            $DB->query('INSERT INTO planimetrie(id_annuncio, planimetria) values('.$_GET['id'].', "'.$immagine.'")');
            fclose($fp);
        }
}

The problem is that when i upload files only from one input, the other input upload anyway an empty file. How can I do?

Thanks, Mattia

  • 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-04T19:11:10+00:00Added an answer on June 4, 2026 at 7:11 pm

    The following code works fine for me, so it may be related to what your doing inside the for statements:

    <?
        if(isset($_FILES['immagini']))
        {
            foreach($_FILES['immagini']['name'] as $index => $name)
            {
                if($_FILES['immagini']['size'][$index] > 0)
                {
                    echo '<br />' . $name;
                }
            }
        }
    
        if(isset($_FILES['plan']))
        {
            foreach($_FILES['plan']['name'] as $index => $name)
            {
                if($_FILES['plan']['size'][$index] > 0)
                {
                    echo '<br />' . $name;
                }
            }
        }
    
    ?>
    <form method="post" enctype="multipart/form-data">
        <input type="file" name="immagini[]" />
        <input type="file" name="immagini[]" />
        <input type="file" name="immagini[]" />
        <input type="file" name="plan[]" />
        <input type="file" name="plan[]" />
        <input type="file" name="plan[]" />
        <input type="submit" />
    </form>
    

    You just then need to do the inserts where the code currently echo’s the name of the file uploaded.

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

Sidebar

Related Questions

I need to upload a given image using Amazon S3 I have this PHP:
If I need a php-page to have access to upload images and move images
I need to upload some data on a site, using a POST request. I
I need to upload a file in C# using an httpwebrequest. I don't need
I need to upload a bunch of files in a directory to S3. Since
I need to upload a large number of content files to an App Engine
I need to upload an image to a remote PHP server which expects the
I am using a HTML form to upload image files. Now i am using
I am practicing with PHP and AJAX but I have some problems! I'm trying
I need to upload a single image to server. The project is using .NET

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.