Hello Diego,

You need to use copy()


If the form input is like this: file: <input name="userfile" type="file">
<input type="submit"

Then PHP will assign a few variables automatically to the file, which
include:

$file_name - actual name of the file (pic.jpg)
$file_size - size in bytes of the file
$file_type - MIME type of the file.

This:
<input type="hidden" name="MAX_FILE_SIZE" value="1000">Send this
Will only let you upload a file of less than 1kb if you program around that
(1024 bytes in a Kb). Setting to 102400 would give you a max upload size of
100 Kb.

So, simply:

<?

if ($file_size < $MAX_FILE_SIZE) {
    @copy($file, "/path/to/dir/" . $file_name)
        or die ("Something's up.");
} else {
    echo "Sorry.  Your file was bigger than the allowed size of  " .
round(($MAX_FILE_SIZE / 1024), 2) ."Kb.  Please go back and try again.";
}

?>

You can of course test whether the file being uploaded is a type you want,
like "image/jpeg" from the $file_type.

Hope this helps.

James.


"Diego Pérez Rández" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
>
>     Hi to all:
>
>     I don`t konw very well php. I do examples everyday and solve some
> problems. But in other i need help.
>
>     Today i want to upload a file. I have the form that you can find in
> the php manual.
>
>     <form enctype="multipart/form-data" action="_URL_" method="POST">
>   <input type="hidden" name="MAX_FILE_SIZE" value="1000">Send this
>   file: <input name="userfile" type="file"> <input type="submit"
> value="Send File">
> </form>
>
>     My problem is that i don´t know how to programe the php program that
> upload the file. I do a lot of examples, but not work.
>
>     Can someone give me help.
>
>
>     Thanks.
>
>
>     Best regards, Diego
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to