I have a very simple script:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<!-- this is up.php -->
<form action="up.php" method="post" enctype="multipart/form-data">
<input type="file">
<input type="submit">
</form>
<?php print_r($_FILES); ?>
</body>
</html>
When I select a file and I click on "Submit" the page is istantly reloaded and nothing happens.
I'm trying with this little script because in a more complex page with other fields everything works well except for the file form. I mean, the database is filled with all the informations provided by my form, but images are not uploaded.
The problem is that the page neither try to upload them, I mean, it should upload them (see the percentage on bottom of page) and then pass it to PHP.
In my case instead the page is istantly submitted and reloaded without the attempt of load pictures.
I have other scripts on my server that upload images, and them works.
Why this one does not work? Thanks.
Edit: live demo here:
http://allise.net/up.php
Actually your file needs to be named most probably.
Try
<input type="file" name="file">
or whatever is set in your up.php file
You need <form method="post" ...> for the form to work.
And the file input should have a name attribute.
Related
This is driving me crazy. I'm trying to figure out how to upload a file. I've got two very simple files, yet it doesn't seem to work. This first is the file that allows the user to choose the file:
<html>
<head>
<title>File Upload Form</title>
</head>
<body>
This form allows you to upload a file to the server.<br>
<form action="getfile.php" method="post"><br>
Type (or select) Filename: <input type="file" name="uploadFile">
<input type="submit" value="Upload File">
</form>
</body>
</html>
</code>
The second is the php file that handles it:
<html>
<head>
<title>Process Uploaded File</title>
</head>
<body>
<?php
print_r($_FILES);
print "<P>\n";
move_uploaded_file ($_FILES['uploadFile'] ['tmp_name'],
"../blimages/site/7337/{$_FILES['uploadFile'] ['name']}")
?>
</body>
</html>
Since -- except for the print_r -- I pulled these off a website tutorial on how to do a file upload, I'd think these files are okay.
The print_r($FILES) return a completely empty array.
I also checked the php.ini. File uploads are allowed, and the max size is 2M, which I assume is 2 megabytes, which is far larger than the file I've been trying to upload.
What else could be wrong?
Thanks,
Sean.
Add the proper enctype attribute to your form tag:
<form action="getfile.php" method="post" enctype="multipart/form-data">
It's documented here: http://www.php.net/manual/en/features.file-upload.post-method.php
Also, make sure there's no space between your brackets when you access multi-dimensional arrays:
$_FILES['uploadFile']['tmp_name']
You shuold use attribute enctype="multipart/form-data" in form tag.
Add that in Form tag
enctype="multipart/form-data"
I have a database with some numbers assigned to a fake account (PHP).
I try to contact the database (with success) and get the right result from the form.
My issue is that the form result open a new page and display there...
I would really like the result to be displayed IN the module I use to send the form OR anywhere else on the same page I used to send the form.
<!DOCTYPE html>
<html>
<body>
<form
method="post"
action="http://ggdbase.dx.am/impulseGetInfo.php"
target="_self">
Account name:<br>
<input type="text" name="name" value="derps">
<br>
<input type="submit" value="Click To Load Account Info">
</form>
</body>
</html>
This is what the module look like (on Enjin.com)
This is what I get when clicking the button
I did try replacing '_self' with '_blank' or parent and all the other options I could find but none of them gave me a different result :S
Could it be caused by the Enjin system itself ?
Do not use target. And replace the action as
action=""
This will ensure that you are calling the same page. Write the PHP code there itself.
Hope that help!
<?php
echo "hello";
?>
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<form action="/one1.php" method="POST" enctype="multipart/form-data">
<input type="file" name="image" />
<input type="submit"/>
</form>
</body>
</html>
`
I have a Url on my server
This url is working. I have written echo "hello" in this.
but when i go through in this url i have written the html file upload code
It says The requested URL [one1.php] was not found on this server.
I checked my file_upload is on.
Make sure your 'action' attribute on form tag is set to /one1.php
I got the answer I contact the hosting team. They told to off the mod security in my panel and things the worked.
I have just started to learn HTML and PHP, but have run into a road block while following beginner tutorials. I am attempting to have the user input numbers into a form on the HTML page, then press submit to redirect to a PHP page that displays the values. The PHP page shows up and successfully displays prepared text but displays nothing for the values.
HTML code:
<html>
<body>
<head>
<title>Practice Page</title>
</head>
<h1>Numbers</h1>
<p>Put numbers in the boxes</p>
<form action="welcome.php" method="post">
NumOne: <input type="text" name="oynumone"><br>
NumTwo: <input type="text" name="oynumtwo"><br>
<input type="submit" value="Submit" id="SubmitRegister" name="submit" />
</form>
</body>
<html>
PHP code:
<html>
<body>
Number one is <?php echo $_POST["oynumone"]; ?><br>
Number two is <?php echo $_POST["oynumtwo"]; ?>
</body>
</html>
Both of the files are simply in the same folder in my documents. I understand that I need a server to host PHP content; I have downloaded MAMP for this, but I don't yet understand how to use it.
Any help would be most appreciated.
Store both file name with .php extension AND/OR update Welcome.php like below -
Welcome.php
<?php
if isset($_POST['submit'])
{
$oynumone = $_POST['oynumone'];
$oynumtwo = $_POST['oynumtwo'];
echo "Number one is ".$oynumone;
echo "Number two is ".$oynumtwo;
}
?>
Also check this
This is driving me crazy. I'm trying to figure out how to upload a file. I've got two very simple files, yet it doesn't seem to work. This first is the file that allows the user to choose the file:
<html>
<head>
<title>File Upload Form</title>
</head>
<body>
This form allows you to upload a file to the server.<br>
<form action="getfile.php" method="post"><br>
Type (or select) Filename: <input type="file" name="uploadFile">
<input type="submit" value="Upload File">
</form>
</body>
</html>
</code>
The second is the php file that handles it:
<html>
<head>
<title>Process Uploaded File</title>
</head>
<body>
<?php
print_r($_FILES);
print "<P>\n";
move_uploaded_file ($_FILES['uploadFile'] ['tmp_name'],
"../blimages/site/7337/{$_FILES['uploadFile'] ['name']}")
?>
</body>
</html>
Since -- except for the print_r -- I pulled these off a website tutorial on how to do a file upload, I'd think these files are okay.
The print_r($FILES) return a completely empty array.
I also checked the php.ini. File uploads are allowed, and the max size is 2M, which I assume is 2 megabytes, which is far larger than the file I've been trying to upload.
What else could be wrong?
Thanks,
Sean.
Add the proper enctype attribute to your form tag:
<form action="getfile.php" method="post" enctype="multipart/form-data">
It's documented here: http://www.php.net/manual/en/features.file-upload.post-method.php
Also, make sure there's no space between your brackets when you access multi-dimensional arrays:
$_FILES['uploadFile']['tmp_name']
You shuold use attribute enctype="multipart/form-data" in form tag.
Add that in Form tag
enctype="multipart/form-data"