phpbar.de logo

Mailinglisten-Archive

[php] Probleme beim file-upload

[php] Probleme beim file-upload

Kai Meder php_(at)_phpcenter.de
Mon, 12 Aug 2002 18:23:39 +0200


http://de.php.net/manual/en/function.move-uploaded-file.php
move_uploaded_file -- Moves an uploaded file to a new location

This function checks to ensure that the file designated by filename is a
valid upload file (meaning that it was uploaded via PHP's HTTP POST
upload mechanism). If the file is valid, it will be moved to the
filename given by
destination.

user-notes:
---------------------------------------------------------
I get an error when using copy() but everything work fine when using
move_uploaded_file().
The error that I get is that open_basedir restriction is in effect, file
is
in the wrong directory.

I get an error (open_basedir restriction is in effect, file
is in the wrong directory. ) when I try to use "copy" when I upload a
file from a form with
a file input.  I think that when php try to copy the temporal file that
Apache use to
store the uploaded file (usually exposed with a ramdom name in the error
messages), the open_basedir restriction (asigned in php.ini) forbid the
action. With move_uploaded_file() there´s no problem.

move_uploaded_file($temp_filename, $destination_filename);
chmod($destination_filename, 0644);
Mode 0644 (the zero is required) will allow everyone to read but not
modify
the file.  That allows you to download it with FTP.  You can use 0666 if
you need to overwrite the file with FTP, but that is probably less
secure.

HTH,
kai


php::bar PHP Wiki   -   Listenarchive