multiple input type file element jquery ajax php mysql

I wan to put 2 input type file in my project meaning i want to be able to upload twice in one insert query. I am searching for sample but i have yet to find any. the only related article i found is this but is does not say much. When i say multiple input file i mean like this.

<input type="file" name="file1"/> - first input file

<input type="file" name="file2"/> - second input file

What i want to happened is select images in one input file and then again select other files(pdf for example) in another input file and be able to insert these files in separate table. I am using ajax in passing the information from html to my server side. I use pdo(php) and my database is mySQL. Any idea is appreciated. Having an example would help best. Especially on how to determine which $_file is from which input file. If I can determine this I think i can be able to insert it to the specific table in server side


How to insert files from 2 input type file element(both can have multiple files)

-------------Problems Reply------------

[file1] => Array
[name] => MyFile.txt (comes from the browser, so treat as tainted)
[type] => text/plain (not sure where it gets this from - assume the browser, so treat as tainted)
[tmp_name] => /tmp/php/php1h4j1o (could be anywhere on your system, depending on your config settings, but the user has no control, so this isn't tainted)
[error] => UPLOAD_ERR_OK (= 0)
[size] => 123 (the size in bytes)

[file2] => Array
[name] => MyFile.jpg
[type] => image/jpeg
[tmp_name] => /tmp/php/php6hst32
[error] => UPLOAD_ERR_OK
[size] => 98174

From here I hope this will solve my problem

Category:php Views:6 Time:2019-01-03

Related post

  • how to validate multiple input type files with jquery validator plugin 2010-07-12

    I am using jQuery validator plugin, i stuck in a problem during validating images, i have 4 input type file to upload image (where one is on page and 3 are coming dynamically)regarding one movie, uploading image is not essential but, if someone wants

  • In jQuery, how can I permanently associate a change() event to an "input type=file" element? 2012-03-19

    How can I trigger a function every time the user selects a file from the "input type=file". I am doing this in jQuery I tried: $(choose_image).on('change','',function(){ .... }); and $(choose_image).change(function(){ .... }); But it only works for t

  • how to pass input type file data in ajax call 2011-05-09

    I've my form <form name="photo" enctype="multipart/form-data" action="<?php echo $_SERVER["PHP_SELF"];?>" method="post"> Photo <input type="file" name="image" size="30" /> <input type="submit" name="upload" value="Upload" />

  • How to handle input type=file in Jquery while uploading file? 2011-08-29

    I searched a lot. Every time anyone asked about file uploading by jquery, as answers he got only some links of jquery plugin. Can anyone tell me why plugin is needed? why simple ajax is not working in this context? Tuition is preferable than solution

  • Which browsers support triggering click event on input[type="file"] elements? 2011-10-26

    According to, Starting in Gecko 2.0 (Firefox 4 / Thunderbird 3.3 / SeaMonkey 2.1) , you can hide the admittedly ugly file element and present your own interface for opening the file p

  • How to attach a javascript FileReader object to an html input[type="file"] element 2012-03-03

    I have the following html <div style="line-height:60px" class="dragzone"> <img width="60px" height="60px" src="" class="image-thumb" style="float: left;" /> <input class="image field" name="test[0][file]" type="file" /> <input ty

  • Selenium WebDriver ElementNotVisible Error for input type='file' element 2013-05-27

    I am using selenium webdriver to try and emulate file uploads I have a file input field: <input class="upload_file_field" id="main_image_file" label="false" name="banner_image_file" type="file" /> Using this in my test results in a ElementNotVi

  • How can the file extension be validated in an input type file using JQuery? 2011-08-12

    HTML: <input type="file" name="group_documents_file" id="group_documents_file" class="group-documents-file" /> Rule: The file to upload must have an extension JPEG, GIF or PNG, otherwise an alert must be displayed. --------------Solutions------

  • How to handle input type=file with jQuery click event on another element 2011-09-07

    I've this code <div id="main"> <div id="u-button">Upload Photo</div> <form id="u_form" action="upload.php" method="post" enctype="multipart/form-data" target="upload_t"> <input id="upload" type="file" name="img" class="mult

  • How to upload file using jquery ajax php 2014-05-17

    I have a file uploading system using jquery's formdata the thing goes like this ---> HTML <form id="upload-form" method="post" enctype="multipart/form-data" action="resource/php/upload.php"> <input style="display:none;" type="file" id="up

  • How to change the button text of input type="file" element 2011-12-02

    Well I am developing a simple page in html, in which I am using input element type="file". By default we get a textbox and a button to browse a file from the system. Default label of this button is Browse. But I want to change the label of this butto

  • How to set Decorators for Input type file Elements? 2011-08-22

    I have the following piece of code, Under myClass , i have set decorators variable, public $testDecorators = array( 'ViewHelper', 'Errors', array('Description', array('escape' => false, 'tag' => '', 'placement' => 'append')), array(array('da

  • jQuery AJAX/ PHP/MySQL live filtering 2011-04-26

    I am building a image gallery where, you can filter images by city, category and gender. The problem I am faced with is how to update the results live (real-time). The logic I apply is: Select a filter criteria, click on a radio button. Send query vi

  • Jquery AJAX PHP MySQL not returning any data (Failing with PHP) 2011-11-12

    I keep getting a failure from my AJAX. I have checked all my PHP in a separate file and it all seems to be working fine. No problems and the json_encode of the created array seems to be good with all the field names and values. Because my understandi

  • Hide information box forever after close with jquery, ajax, php, mysql 2011-08-02

    so I am wondering the best way to go about this and thought id get some input. I have information boxes with close buttons on them and am currently using jquery to hide the boxes. The problem is, if the user closes the information box, I would like t

  • Jquery Ajaxform with input type=file and multifile 2010-06-13

    Im using ajax form with multifile. However ajaxform just seems to quietly die and does not do anything if using multifile. Multifile is just a jquery plugin that builds a list of input type=file so that you can upload multiple files at once, before w

  • Unbinding input type file button with jquery doesn't work 2012-03-26

    I have an input type file element: <input type="file" name="val1" /> And jquery: $("input[name='val1']").off("click"); But the above JS script (already included in $(function() { }); block) doesn't work, means I can click on Browse... button. I

  • Styling an input type="file" button 2009-02-21

    How to style the input type="file" button. --------------Solutions------------- Styling file inputs is notoriously difficult, as most browsers will not change the appearance from either css or javascript. Even the size of the input will not respond t

  • input type=file show only button 2009-07-05

    Is there a way to style (or script) <input type=file /> element to have visible only "Browse" button without text field? Thanks Edit: Just to clarify why to I need this. I'm using multi file upload code from and it

  • Change cursor type on input type="file" 2009-10-08

    Simple question... How do I change the cursor type on a file input type? I've tried the following: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" ""> <html> <head> <style

  • Input [type=file] returns empty value 2012-01-15

    I have a script that creates a popup with form according to webpy cookbook: jQuery('#logo').click(function(){ var content = ('<h1>Upload logo</h1>' + '<form method="POST" enctype="multipart/form-data" action="/upload">' + '<input

  • Upload files using input type="file" field with .change() event not always firing in IE and Chrome 2012-04-18

    I have simple piece of code to upload files: $(document).ready(function () { $(".attachmentsUpload input.file").change(function () { $('form').submit(); }); }); <form class="attachmentsUpload" action="/UploadHandler.ashx" method="post" enctype="mu

  • How to keep input type=file field value after failed validation in ASP.NET MVC? 2009-06-09

    I've got a simple form in an MVC app I've made. It contains a file field so users can upload an image. It all works great. Problem is, if the form submit fails validation the content of the file field is lost (other fields remain populated, thx HtmlH

  • How to RESPOND to a click event on an input type=file in non IE browsers 2011-03-02

    So here's the scenario- Unlike the 3000 other questions on StackOverflow about how to INVOKE the click event on an input[type=file] element, I just want to respond to it. I'm looking for something like: <input id="theFile" onclick="var that=this;s

  • Hide the browse button on a input type=file 2011-06-16

    Is there a way to hide the browse button and only leave the text box that works in all browsers? I have tried setting the margins but they show up different in each browser --------------Solutions------------- No, what you can do is a (ugly) workarou

Copyright (C), All Rights Reserved.

processed in 0.096 (s). 11 q(s)