[Fwd: php3 question...]

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Shawn T. Rutledge
Date:  
Subject: [Fwd: php3 question...]
--8t9RHnE3ZwKMSgU+
Content-Type: text/plain; charset=us-ascii

On Fri, Mar 17, 2000 at 07:18:09AM -0700, Eric Samson wrote:
> I am trying to upload files through a form, and trying to put them into
> a temporary directory to transfer them to a permanent file... I have
> the Wrox php book, and I am totally lost at this point... I guess there


What is wrox?

> is a default temp directory where this stuff is put, but I have no clue
> how to determine where that is... Can anyone help? Thanks in advace
> all....
>
> This is what I coded:
>
> if ($file1) {
>      if (copy($file1,"/temp/$lname")) {
>       echo ("<B>Photo 1 received:  thank you!</B>");
>      } else {
>       echo ("<B>Error saving photo 1. </B>" . "However, your information
> will still be processed.");
>      }
>     }

>
>     if ($file2) {
>      if (copy($file2,"/temp/$lname")) {
>       echo ("<B>Photo 2 received:  thank you!</B>");
>      } else {
>       echo ("<B>Error saving photo 2. </B>" . "However, your information
> will still be processed.");

>
> This is the warning:
>
> Warning: Unable to open 'none' for reading: No such file or directory in
> /usr/local/apache/htdocs/php/adinfo_action.php3 on line 232
> Error saving photo 1. However, your information will still be processed.


Well it looks like the name of the form field where you upload the file
should be "lname". Check that; also check to make sure /temp exists
(did you mean /tmp?)

I'll attach a script that works for me, and the upload form to go with
it. This is what I use to upload things to my home directory (and
authentication is required, it's not for anonymous upload).

-- 
  _______                                     http://www.bigfoot.com/~ecloud
 (_  | |_)     finger 
 __) | | \__________________________________________________________________
 Get money for spare CPU cycles at http://www.ProcessTree.com/?sponsor=5903


--8t9RHnE3ZwKMSgU+
Content-Type: text/html
Content-Disposition: attachment; filename="upload.html"

<center>
<FORM ENCTYPE="multipart/form-data" ACTION="upload.php3" METHOD="POST">
<INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="5000000">
File: <INPUT NAME="userfile" size=60 TYPE="file"><BR>
<INPUT TYPE="submit" VALUE="Send File">
</FORM>
</center>

--8t9RHnE3ZwKMSgU+
Content-Type: application/x-httpd-php3
Content-Disposition: attachment; filename="upload.php3"

<?
    echo "userfile $userfile<BR>\n";
    echo "userfile_name $userfile_name<BR>\n";
    echo "userfile_size $userfile_size<BR>\n";
    echo "userfile_type $userfile_type<BR>\n";
    if (copy($userfile, "/home/rutledge/public_html/$userfile_name"))
    {
        echo "$userfile_name has been uploaded<br>\n";         
    }
    else 
    {
        echo "Upload directory not write-enabled\n";
        $error1 = 1;                                      
    }
?>


--8t9RHnE3ZwKMSgU+--