<label class="labelFile">Bestand kiezen...</label>
<input type="file" name="images_1" class="fileChoose" accept="image/*"></br></br></br>
<label class="labelFile">Bestand kiezen...</label>
<input type="file" name="images_2" class="fileChoose" accept="image/*"></br></br></br>
It only fills the first image and the second one it gives an errors: "4", how to fix it,
I want multiple input fields not 1 multiple :D
if you put the form with
<form method="POST" enctype="multipart/form-data" >
two items are returned to you
try like this
<?php
var_dump($_FILES['images_1']);
var_dump($_FILES['images_2']);
?>
<form method="POST" enctype="multipart/form-data" >
<label class="labelFile">Bestand kiezen...</label>
<input type="file" name="images_1" class="fileChoose" accept="image/*"></br></br></br>
<label class="labelFile">Bestand kiezen...</label>
<input type="file" name="images_2" class="fileChoose" accept="image/*"></br></br></br>
<button value="ppp" type="submit">send </button>
</form>
Related
I have this form:
<label for="pdffile">Upload</label>
<form class="form-horizontal" role="form" method="POST" name="upload" id="upload" enctype="multipart/form-data">
{{ csrf_field() }}
<input type="file" id="pdffile" style="display:none" form="upload"
</form>
It is supposed to be submitted with this jquery:
$('#pdffile').change(function() {
$('#upload').attr("action", "/upload").submit();
});
However when I check in PHP, nothing is uploaded:
dd($request)
Always gives me back null instead of the requested item.
Any help?
Your input does not have name
<input type="file" id="pdffile" style="display:none" form="upload"
change to
<input type="file" id="pdffile" style="display:none" name="upload"/>
and in your action you can use $_FILES to get upload file
Source Code :
<form role="form" action="uploadrit.php" method="post" enctype="multipart/form-data">
<label class="input" >Choose File Of CSV Format</label>
<input class="input" type="file" name="file" id="file" class="form-control" required="required">
<button class="input" type="submit" name="AddFile" class="btn btn-primary">Submit</button>
</form>
I want to select all file from directory using file upload control and send one by one file to uploadrit.php.
You should add multiple attribute to your file tag:
<form role="form" action="uploadrit.php" method="post" enctype="multipart/form-data">
<label class="input" >Choose File Of CSV Format</label>
<input class="input" type="file" name="file" multiple id="file" class="form-control" required="required">
<button class="input" type="submit" name="AddFile" class="btn btn-primary">Submit</button>
</form>
If you need to handle the files via Javascript, you can use File API. Example documentation: http://developer.mozilla.org/en-US/docs/Using_files_from_web_applications
Instead sending the files one by one, use the multiple flag and send the files as an array. Here is an example:
<form action="file-upload.php" method="post" enctype="multipart/form-data">
<input type="file" name="files[]" multiple>
<input type="submit" value="Upload">
</form>
Pay attention to input where I've used the multiple flag as well as have declared the name of the input as an array. In your PHP file, loop through $_FILES['files'] to get all selected files.
Have a look at the following code:
<?php
if (isset($_POST['email']))
{
$expertmail=trim($_POST['email']);
echo $expertmail;
$expertfile=$_FILES['upfile']['tmp_name'];
echo $expertfile;
}
?>
<form action="test.php" method="post" name="users" id="users" >
<input name="upfile" id="upfile" type="file" />
<input name="email" id="email" type="text" />
<input type="submit" name="submit_button" id="submit_button" value="ΑΠΟΣΤΟΛΗ" />
</form>
Why 'echo $expertfile' does not display anything?
Thank you
POST Method Uploads gives all the information you need to handle file uploads in PHP. For your case you need: enctype="multipart/form-data":
<form action="test.php" method="post" name="users" id="users" enctype="multipart/form-data">
As Salman A points out, you will also need to check to see if a file was uploaded.
In my index.php file , I got a code is trace the $_FILE, but seems like when uploaded a pic/jpeg/images file, the return result is 'array(0) { }'. Did I need use smarty's method to assign a input file's method?
var_dump($_FILES);
my photoupload.tpl
<form action="index.php?view=photoupload" method="post" enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file">
<input class="btn_name" type="submit" name="submit" value="Submit">
</form>
No, you dont have to, heres a part of my current project where i work with smarty:
<form action="upload_contract.php" enctype="multipart/form-data" method="post">
...
<div class="row">
<div class="large-5 columns">
<label for="upload">Dateiupload:</label><span><input type="file" id="upload" name="upload"></span>
</div>
</div>
This one works fine without additional methods.
I have a form, like this
<form id="picuploadform" enctype="multipart/form-data" method="post" action="">
<div class="row">
<label for="fileToUpload">Select a File to Upload</label><br />
<input type="file" name="fileToUpload" id="fileToUpload" />
<input type="hidden" id = "picssn" name="picssn" value="qweweqwq">
</div>
<div class="row" style="width:150px;">
<input type="submit" value="Upload" />
</div>
</form>
Which when I click the submit button I have PHP on this page to process it just fine. $_FILES for receiving file and $_POST for reading picssn that came with the hidden input. But due to problem with Jquery mobile I can't use submit or .submit() now. So I want to use
$.post('myphpfile.php', {picssn:$('#picssn').value(), file: $('#fileToUpload').xxxxxxxxxxxxxxxxx });
instead. But I have no idea how to grab the file out of that form and send it this way. Is there some method that can replace xxxxxxxxxxxxxx ? Thanks!
On your form element, you need to disable the ajax submit, and then fix your other code.
Try this:
<form id="picuploadform" enctype="multipart/form-data" method="post" action="#" data-ajax="false">
<div class="row">
<label for="fileToUpload">Select a File to Upload</label><br />
<input type="file" name="fileToUpload" id="fileToUpload" />
<input type="hidden" id = "picssn" name="picssn" value="qweweqwq">
</div>
<div class="row" style="width:150px;">
<input type="submit" value="Upload" />
</div>
</form>
You cant upload directly via ajax. Check this perhaps:
http://blueimp.github.com/jQuery-File-Upload/ or uploadify.com