I have a simple dialog box:
<div data-role="dialog" id="uploadImage" data-title="Upload Image" data-needs-auth="true">
<div data-role="header" data-position="fixed" data-theme="b">
<h1>Upload Image</h1>
</div><!-- /header -->
<div data-role="content">
<form name=uploadForm method=post enctype="multipart/form-data" action="uploadbi.php" data-ajax="false">
<input type=file name=filename>
<input type=hidden name=MAX_FILE_SIZE value=8000000>
<input type="submit" value="Upload Image" data-theme="a" data-inline="true">
</form>
</div>
</div>
</div>
The problem is that it does not pass the filename field. From Firebug:
Post Parameters
application/x-www-form-urlencoded
MAX_FILE_SIZE 8000000
seid 6e540f68067707233241eb170ca83c43
Source
MAX_FILE_SIZE=8000000&seid=6e540f68067707233241eb170ca83c43
This is running under Firefox and I verified that it also fails under Chrome. It's been forever since I've dealt with file uploads in a form. What am I missing?
Last month I had a similar problem. Try to add data-ajax="false" on your form definition and see if that will help.
For more information, you could check this link.
Related
With Bootstrap 4.0.0
<div class="container">
<div class="jumbotron mt-3" style="padding: 0.6em 1.6em;">
<h4>Uploader</h4>
<form enctype="multipart/form-data" action="/myurl/?action=upload" method="POST">
<input type="file" class="form-control-file">
<input type="submit" class="btn btn-primary" name="Upload">
</form>
</div>
</div>
In combination with this PHP code on the other side:
<?php var_dump($_FILES); ?>
returns:
array(0) { }
In other words: I simply select a file, /myurl/?action=upload is called, but empty($_FILES['myfile']) is TRUE / no files seems to be passed.
What is the issue?
Thanks
The issue is that you haven't provided a proper name attribute in your input field.
<input type="file" class="form-control-file" name="uploaded_file">
Would likely help this issue, but without seeing your PHP, it could be other issues.
first of all sorry for my bad English. I have hit a point in my project that i can't finde a solution on, so I will ask for help.
First let me explain a little about what the project is:
The system is a big upload system for a customer. each file there are selected need a Title.
As you can see I have many "Chose File" that because there need to be a max number of files pr categories (this can be change invidually) and the Title (the box beside the orange upload) are Required if you have chose a file.
My problem:
Click upload on each category are ignoring so wanna make one button to push there activate the upload for all those files. that easy enough, but here it's come: at the Host this system run on the max "upload size" is 90MB so when I have multiple files at the same time, its hit really quick the max.
This is how the HTML looks:
<form method='POST' accept-charset='UTF-8' enctype='multipart/form-data' >
<div class="inputs">
<label for="uMP1">Vælg Fil</label>
<input type="text" name='titles[]'>
<!-- Thumbnail -->
<div class="thumbnail" id="MP1"></div>
<!-- File -->
<input id="uMP1" name='files[]' type="file">
</div>
<div class="inputs">
<label for="uMP2">Vælg Fil</label>
<input type="text" name='titles[]'>
<!-- Thumbnail -->
<div class="thumbnail" id="MP2"></div>
<!-- File -->
<input id="uMP2" name='files[]' type="file">
</div>
<div class="inputs">
<label for="uMP3">Vælg Fil</label>
<input type="text" name='titles[]'>
<!-- Thumbnail -->
<div class="thumbnail" id="MP3"></div>
<!-- File -->
<input id="uMP3" name='files[]' type="file">
</div>
<input type="Submit" name='Upload' value="Upload">
</form>
Is there any there can help me make this script or know a plugin there can do this?
PS: Do not have access to the php.ini
Premise that I have never used PHP, but ASPNET Core 2.1
I also had a similar problem and the solution is to give different names for each input file.
For example:
<div class="inputs">
<label for="uMP1">Vælg Fil</label>
<input type="text" name='titles[]'>
<!-- Thumbnail -->
<div class="thumbnail" id="MP1"></div>
<!-- File -->
<input id="uMP1" name='files1' type="file">
</div>
<div class="inputs">
<label for="uMP2">Vælg Fil</label>
<input type="text" name='titles[]'>
<!-- Thumbnail -->
<div class="thumbnail" id="MP2"></div>
<!-- File -->
<input id="uMP2" name='files2' type="file">
</div>
I am planning to make a form which has a form through which users can upload a file on the website.
I used a CSS template where a class called pop-up-wrapper and pop up is defined. However, when I use the following code :
<div>
<div class="form-pop-up">
<div class="form-pop-up-wrapper">
<ul class="contact-form">
<form id="form-submit" method="post" enctype="multipart/form-data">
<li>
<p class="iam-white center-al">Upload file</p>
<input type="file" name="resume" id="user-resume">
</li>
<li>
<p> </p>
<input type="submit" name="submit" value="Submit" id="form-submit" class="mar">
</li>
</form>
</ul>
</div>
</div>
</div>
I have a PHP code which validates if any file has been entered by checking with
isset($_FILES['file']
but this always returns 0.
Is there anything in the CSS stylesheet which can lead to this situation where $_FILES is unable to catch the uploaded file?
TIA
You have to use the name in $_FILES, not the type.
isset($_FILES['resume'])
Just a shot here, but I don't think it's your CSS that's causing the problem. Try:
isset($_FILES['resume'])
instead.
I'm building a mobile website using jQuery Mobile and PHP.
Currently, when I submit a form with PHP, it redirects me to the previous page.
However, I want to stay on the same page.
Here's my code:
<form action="#" method="post" data-ajax="false">
<center>
<div data-role="page">
<div data-role="collapsible" data-iconpos="right" data-theme="a" style="width:500px">
<h3>Offer 1</h3>
<img src="images/special1.jpg"/>
<h3>Valid through: 06/30/2013</h3>
<div data-role="collapsible" data-collapsed="true" data-iconpos="right" data-theme="a" style="width:400px; background-color:#FFFFFF">
<h3>Redeem this offer</h3>
<div >
<h4 style="color:#CC0000"> To be used by our staff only!</h4>
<p style="color:#CC0000;font-family:Arial, Helvetica, sans-serif">Do <strong>not</strong> press the Redeem button now. Ask our store associate for assistance.</p>
<input type="submit" name="offer1btn" value="Redeem" data-theme="b" style="background:#FF0000 !important"/>
</div>
<div style="display:none">
<h4 style="color:#CC0000">Offer has been Taken</h4>
</div>
</div>
</center>
</form>
Or you can use
action="<?php echo $_SERVER['PHP_SELF'];?>"
hope that helps.
jQuery Mobile is a little bit specific with form submitting. If you disable classic jQuery Mobile form handling with data-ajax="false" attribute then only correct way to submit a form is through $.ajax call.
I made a working example here: jQuery Mobile: How to correctly submit form data
I have this code. Trying to pass form values from one internal page to the other and it's not working.
Here's the code:
<div data-role="page" id="home">
<div data-role="header">
<h1>Page One</h1>
</div><!-- /header -->
<div data-role="content">
<form action="post" name="myform">
<input type="text" value="" name="mytext" />
<input type="submit" value="submit" />
</form>
</div><!-- /content -->
</div><!-- /page -->
//And page 2
<div data-role="page" id="page2">
<div data-role="header">
<h1>Page Two</h1>
</div><!-- /header -->
<div data-role="content">
<?php if (isset($_POST['mytext'])) {
// do something with $_POST['value']
echo 'it works'; } ?>
</div><!-- /content -->
</div><!-- /page -->
It's basically not working ... no errors but no values either.
Your action should be the php script that is going to process your post variables and method should be post.
<form action="somefile.php" method="post">
Most likely the error is here:
<form action="post" name="myform">
<input type="text" value="" name="mytext" />
<input type="submit" value="submit" />
</form>
action is supposed to be the handler of the form, either the same page or another one (where the php script that elaborates the form resides). POST is the METHOD. (which can be either GET or POST)
So it should be:
<form action="" method="POST" name="myform"> <!-- action = "" reloads the same page, otherwise you could write action="myphppage.php" or whatever -->
<input type="text" value="" name="mytext" />
<input type="submit" value="submit" />
</form>
<form action="post" name="myform">
is wrong.
It should be something like:
<form method="post" name="myform" action="">
You need to send a POST method. The action is empty so it sends it to the page itself.
The 'action' should be the page that is the destination URL. You have mixed up method="post" with action="post". Set the action as "second_page.php".
I didn't fully understand what you meant by internal page, but if it is the same page, only a different div, then leave the action as blank(action='').