PHP5: file upload: is_uploaded_file == false

Hello,
I need to implement file upload on .php page. To do so I have written in
Paper.php:

<form id="AddEdition" name="AddEdition" action="AddEdition.php"
method="POST" enctype="multipart/form-data" onsubmit="return
ValidateEdition();">
<input type="file" id="SelectEditionFile" name="SelectEditionFile"
onblur="PassFile();" />
<input type="hidden" value="" id="EditionFile" name="EditionFile" />
<input type="text" id="Year" name="Year" /></td>
<select id="Month" name="Month">
<option value="01">January</option>
<option value="02">February</option>
<option value="03">March</option>
...
<option value="12">December</option>
</select>
<input type="submit" value="Send file" /> <input type="reset"
value="Cancel" /></td>
</form>
<script type="text/javascript">
var today = new Date();
document.AddEdition.Year.value = today.getFullYear();
function PassFile()
{
document.getElementById('EditionFile').value =
document.getElementById('SelectEditionFile').value;
}
</script>

(onblur is used because of bug.)
The file AddEdition.php is:

<?php
session_start();
require 'Scripts.inc';
if ($_SERVER['REQUEST_METHOD'] == 'POST' &&
isset($_POST['EditionFile']) && isset($_POST['Year']) &&
isset($_POST['Month']))
{
if (is_uploaded_file($_FILES['SelectEditionFile']['tmp_name']))
{
$file = $_FILES['SelectEditionFile']['name'];
$ext = [at] substr($file,
[at] strrpos($file, '.') ? [at] strrpos($file, '.') + 1 : [at] strlen($file),
[at] strlen($file));
$paper = 'Paper/Blask_' . $_POST['Year'] . '-' . $_POST['Month'] . '.' .
$ext;
[at] unlink($paper);
if (!move_uploaded_file($_FILES['SelectEditionFile']['tmp_name' ], $paper))
{
$_SESSION['Error'] = 'Failed to move the file.';
}
}
else
{
$_SESSION['Error'] = 'Failed to upload file.';
}
}
header("Location: Paper.php?topic=Editions");
?>

The problem is that is_uploaded_file(...) returns false (I have verified).
I don't understand why. Please help.
/RAM/
r_ahimsa_m [ Di, 08 Januar 2008 16:09 ] [ ID #1902911 ]

Re: PHP5: file upload: is_uploaded_file == false

R.A.M. schreef:
> The problem is that is_uploaded_file(...) returns false (I have verified).
> I don't understand why. Please help.
> /RAM/
>

Perhaps the max upload size in your ini file is too small for the file
you are testing.

Check the value of the $_FILES['SelectEditionFile']['error'] key.


JW
Janwillem Borleffs [ Di, 08 Januar 2008 16:51 ] [ ID #1902917 ]

Re: PHP5: file upload: is_uploaded_file == false

Thanks.

Uzytkownik "Janwillem Borleffs" <jw [at] jwscripts.com> napisal w wiadomosci
news:47839bff$0$17296$dbd41001 [at] dr3.euro.net...
> Check the value of the $_FILES['SelectEditionFile']['error'] key.

It is 11.
This value is not described in
http://pl2.php.net/manual/pl/features.file-upload.errors.php
Do you know what it means?
/RAM/
r_ahimsa_m [ Do, 10 Januar 2008 05:19 ] [ ID #1904736 ]

Re: PHP5: file upload: is_uploaded_file == false

R.A.M. schreef:
> It is 11.
> This value is not described in
> http://pl2.php.net/manual/pl/features.file-upload.errors.php
> Do you know what it means?
> /RAM/
>

It's probably an OS dependent exit code, check the other keys in the
$_FILES array.

When, per example, the file size is 0, then you will have to check if
the directory PHP writes the uploaded data to is writeable for the web
server user.


JW
Janwillem Borleffs [ Fr, 11 Januar 2008 11:33 ] [ ID #1905556 ]

Re: PHP5: file upload: is_uploaded_file == false

Sorry, the code was 1. File was to big.
Thank you, you have helped me.
/RAM/
r_ahimsa_m [ Fr, 11 Januar 2008 23:55 ] [ ID #1905588 ]
PHP » comp.lang.php » PHP5: file upload: is_uploaded_file == false

Vorheriges Thema: String Contains Function
Nächstes Thema: New to PHP Facebook group