Re: copy() for file upload
| From: | Wayne | Date: | Fri, 28 Feb 2003 06:48:07 +0000 |
| Subject: | Re: copy() for file upload | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-18751@lists.php.net to get a copy of this message | ||
the copy $FILE_name var needs to be
$NAME-OF-FIELD_name [that should return the proper thing] (i think)
this is a php script i use to upload some avatar (image) files etc
maybe it will help
--------------------
<form method="post" enctype="multipart/form-data"
action="Avatar.php">
<input type="hidden" name="action" value="put">
<input type="file" name="avf" size=20> <input type="submit"
value="Put
File">
</form>
<?php
error_reporting(E_ALL);
if($action == "put"){
if(is_uploaded_file($avf)){
if(is_file("modules/Chat/Avatars/".$avf_name)){
unlink("modules/Chat/Avatars/".$avf_name);
}
copy($avf,"modules/Chat/Avatars/".$avf_name);
chmod("modules/Chat/Avatars/".$avf_name,0777);
}
}
?>
---------------------
<thomash@gmx.co.za> wrote in message news:14611.1044432996@www55.gmx.net...
> Hi guys,
>
> I realize that this might be rather a question for the general list, but i
> will try it here anyway (still have to subscribe to general).
> I am using the copy() method to upload pictures to my site. However, i am
> experiencing all sorts of problems. The most common one is that it does
not
> find the 'on-the-fly' variable called $File_name. This var gets created
with the
> filename of the upload picture.
> Here are the two error messages i encounter:
>
> 1. Running Linux:
>
> Warning: Unable to open 'C:\\Documents and Settings\\Thomash\\My
> Documents\\My Pictures\\ieeelogo2.gif' for reading: No such file or
directory in
> /usr/www/users/thomasd/members/mypictures.php on line 37
>
> Warning: unlink() failed (No such file or directory) in
> /usr/www/users/thomasd/members/mypictures.php on line
> 38
>
> --------------------------------------------------------------------------
---------------------------------
>
> 2. Windows 2000:
>
> Notice: Undefined variable: File_name in
> c:\inetpub\wwwroot\pdev\thomash.net\members\mypictures.php on line 37
>
> Warning: copy(../images/mypictures/_general/uploads/) [function.copy]:
> failed to create stream: Permission denied in
> c:\inetpub\wwwroot\pdev\thomash.net\members\mypictures.php on line 37
>
> Notice: Undefined variable: File_name in
> c:\inetpub\wwwroot\pdev\thomash.net\members\mypictures.php on line 43
>
> --------------
>
> Both times Apache is used.
>
> Thomas Hochstetter
>
> --
> +++ GMX - Mail, Messaging & more http://www.gmx.net +++
> NEU: Mit GMX ins Internet. Rund um die Uhr für 1 ct/ Min. surfen!
>