PHP5: file upload: is_uploaded_file == false

PHP5: file upload: is_uploaded_file == false

am 08.01.2008 16:09:44 von r_ahimsa_m

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

method="POST" enctype="multipart/form-data" onsubmit="return
ValidateEdition();">
onblur="PassFile();" />



value="Cancel" />



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

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 = @substr($file,
@strrpos($file, '.') ? @strrpos($file, '.') + 1 : @strlen($file),
@strlen($file));
$paper = 'Paper/Blask_' . $_POST['Year'] . '-' . $_POST['Month'] . '.' .
$ext;
@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/

Re: PHP5: file upload: is_uploaded_file == false

am 08.01.2008 16:51:27 von Janwillem Borleffs

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

Re: PHP5: file upload: is_uploaded_file == false

am 10.01.2008 05:19:05 von r_ahimsa_m

Thanks.

Uzytkownik "Janwillem Borleffs" napisal w wiadomosci
news:47839bff$0$17296$dbd41001@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/

Re: PHP5: file upload: is_uploaded_file == false

am 11.01.2008 11:33:25 von Janwillem Borleffs

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

Re: PHP5: file upload: is_uploaded_file == false

am 11.01.2008 23:55:29 von r_ahimsa_m

Sorry, the code was 1. File was to big.
Thank you, you have helped me.
/RAM/