Php upload file

A

Anonymous

Guest
:?:

Hello

I try to upload file but ...

Here my form :

<form method="post" enctype="multipart/form-data" action="uploadtst.php">
<INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="1000">
<input type="file" name="userfile">
<input type="submit">
</form>

in this part of code

<?
if (is_uploaded_file($userfile)) {
move_uploaded_file($userfile, "/place/file.new");
}
?>
I never reach into the if condition and so I can't make the move.
Can you help me ?

Thanks
Cordially
Stéphane Vauclaire
 
is_uploaded_file is vaguely deprecating in favour of the reg_globs OFF and $_FILES array manner of addressing variables

if($_FILES['userfile']['error'] == 0)
{
// we have an upload
// usable vars
echo '
'temporary file name = ' .$_FILES['userfile']['tmp_name']. '<br />
'file size = ' .$_FILES['userfile']['size']. '<br />
'client original file name = ' .$_FILES['userfile']['name']. '<br />
'file type - from headers = ' .$_FILES['userfile']['type'];
}

so

move_uploaded_file($_FILES['userfile']['tmp_name'], 'place/file.new');

should be ok

note: ['error'] returns values from 0 to 4 where zero is success
 
Hello

It can't work when I wrote

Code:
echo $_FILES['userfile']['error'];

It answers 2.

Can you tell me more ?

Thanks
Cordially
Steff
 
look for the file upload articles on phpbuilder .com webmonkey.com and hotscripts.com
and the manual
,,.... :arrow:
 
UPLOAD_ERR_OK

Value: 0; There is no error, the file uploaded with success.
UPLOAD_ERR_INI_SIZE

Value: 1; The uploaded file exceeds the upload_max_filesize directive in php.ini.
UPLOAD_ERR_FORM_SIZE

Value: 2; The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form.
UPLOAD_ERR_PARTIAL

Value: 3; The uploaded file was only partially uploaded.
UPLOAD_ERR_NO_FILE

Value: 4; No file was uploaded.

Note: These became PHP constants in PHP 4.3.0

Read http://uk.php.net/manual/en/features.file-upload.php
 
hi!
try to change some code like this:
Code:
<? 
if (is_uploaded_file($userfile)) { 
  move_uploaded_file($userfile, '/place/file.new'); 
} 
?>
then you use manipulation of files to you need use once quotes not double PHP understand "filename" like string, not like path to file.....
by the way in include too same.......
 
Back
Top