|
Posted by Rik on 02/15/07 13:43
On Thu, 15 Feb 2007 14:18:46 +0100, Daniele <"dmassaiu{["@]}yahoo.co.uk>=
=
wrote:
> Rik wrote:
>> On Thu, 15 Feb 2007 13:52:40 +0100, jodleren <sonnich@hot.ee> wrote:
>>>> > <form method=3Dpost name=3D'myform' action=3D'the_file_itself'>
>>>>
>>>> <form enctype=3D"multipart/form-data" method=3D"post" action=3D"/">=
>>>>
>>>> Enctype is important.
>>>
>>> Thanks. I asume that it does not stop me from checking other actions=
>>> in my form?
>>> I cannot test yet :-)
>> Any other normal postvalue is just handled fine indeed.
> try this
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" =
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
New code, where is it transitioning from? New code should always be =
strict...
> <html xmlns=3D"http://www.w3.org/1999/xhtml">
> <head>
> <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Diso-=
8859-1" =
> />
> <title>Untitled Document</title>
> </head>
Open the body tag here, <pre> is illegal in the <head>
> <?
> if (isSet($_POST['add'])) {
> $uploaddir =3D '.';
> $uploadfile =3D $uploaddir . basename($_FILES['file']['name']);
>
> echo '<pre>';
> if (is_uploaded_file($_FILES['file']['tmp_name'])) {
> echo "file upload in " . $_FILES['file']['tmp_name'] ."\n";
> }
> if (move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile)) {
> echo "File was successfully uploaded.\n";
> } else {
> echo "File was NOT successfully uploaded.\n";
> }
What about:
switch($_FILES['file']['error']){
case UPLOAD_ERR_OK:
echo 'upload was fine';
if(move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile)){
echo 'file was succesfully moved';
} else {
echo 'file could not be moved to '.$uploadfile;
}
break;
case UPLOAD_ERR_INI_SIZE:
echo 'file was bigger then allowed in php.ini';
break;
case UPLOAD_ERR_FORM_SIZE:
echo 'file was bigger then allowed in MAX_FILE_SIZE in the form';
break;
case UPLOAD_ERR_PARTIAL:
echo 'file was only partially uploaded';
break;
case UPLOAD_ERR_NO_FILE:
echo 'no file was uploaded';
break;
case UPLOAD_ERR_NO_TMP_DIR:
echo 'no temporary folder to write upload to';
break;
case UPLOAD_ERR_CANT_WRITE
echo 'problem writing file to disk';
break;
case UPLOAD_ERR_EXTENSION
echo 'file-upload stopped by extention';
break;
default:
echo 'Unknown error';
print_r($_FILES);
}
Seems a bit more informative.
-- =
Rik Wasmus
Navigation:
[Reply to this message]
|