Omnimaga
General Discussion => Technology and Development => Web Programming and Design => Topic started by: Munchor on September 11, 2011, 03:24:49 pm
-
<form action="upload.php" method="POST" enctype="multipart/form-data">
<input type="file" name="file" id="file"><br>
<input type="submit" name="submit" value="Submit">
</form>
I have this form and I would like to know, in the upload.php file if anything was submitted in the type="file".
This tells me nothing was submitted, even when I submitted a file:
<?php
if (empty($_FILES["file"]["file"]))
{
echo "No file was submitted, try again.";
}
?>
This also tells me nothing was submitted, even when I submitted a file:
<?php
if (empty($_POST["file"])
{
echo "No file was submitted, try again.";
}
?>
Thanks in advance!
-
http://www.php.net/manual/en/function.is-uploaded-file.php
Is that what you're looking for? is_uploaded_file($_FILES['file']['tmp_name']), in your case.
-
http://www.php.net/manual/en/function.is-uploaded-file.php
Is that what you're looking for? is_uploaded_file($_FILES['file']['tmp_name']), in your case.
Great, that worked. But that doesn't work in all servers does it? I am thinking it may only work in Linux servers, but I might be wrong. Thanks! I am saying this because you said "in your case".
-
Should work for all. "tmp_name" doesn't mean /tmp in *nix, it just refers to where the temp area for the uploaded file may be. ;)
Typically, for Windows the temp dir would be C:\Windows\Temp (but don't try accessing it directly :P).
-
http://www.php.net/manual/en/function.is-uploaded-file.php
Is that what you're looking for? is_uploaded_file($_FILES['file']['tmp_name']), in your case.
Great, that worked. But that doesn't work in all servers does it? I am thinking it may only work in Linux servers, but I might be wrong. Thanks!
The PHP manual will tell you when it will and won't work with certain servers. I don't see any notes on this page, so I'm guessing it should work.I am saying this because you said "in your case".
Oh no, all I meant was that since you're uploading files under the name "file," your $_FILES variable would be $_FILES['file'].
-
Thanks everybody, I managed to do it, and I understood how it works ;)