I found the problems:
1. I shouldn't have been using stripslashes() when putting the picture on
the filesystem.  This would have been necessary for adding the image to a
database.
2. Put ENCTYPE=multipart/form-data in <form>.  My bad, I didn't include the
<form> part of my code in the email.

Tyler Longren
Captain Jack Communications
[EMAIL PROTECTED]
www.captainjack.com


----- Original Message -----
From: "Tyler Longren" <[EMAIL PROTECTED]>
To: "php-general" <[EMAIL PROTECTED]>
Sent: Wednesday, July 25, 2001 11:24 AM
Subject: [PHP] remote image uploads.


> Hello everyone,
>
> I've hunted on google, read the list archives.  Here's what I've been
> fooling with to upload the file:
> $data = addslashes(fread(fopen($picture, "r"), filesize($picture)));
>                             $len = strlen($data);
>                             if ($fp = fopen("$image_path/$picture_name",
> "wb")) {
>                                     if ($size = fwrite($fp, $data, $len))
{
>                                             print "<font face=Arial
> size=2>Thanks, the image has been added to our database.</font>";
>                                             fclose ($fp);
>                                     }
>                                     else {
>                                             print "<font face=Arial
> size=2>$picture_name couldn't be written to, perhaps some permissions are
> wrong?";
>                                     }
>                             }
>                             else {
>                                     print "<font face=Arial
> size=2>$picture_name couldn't be opened (or created), please try
> again.</font>";
>                             }
>
> Here's the relavent form field:
> <input type=file name=picture>
>
> And here's the errors:
> Warning: fopen("C:\\WINDOWS\\Desktop\\whiterain.jpg","r") - No such file
or
> directory in /home2/aanr.com/www/cyber_bulletin/admin/add.php on line 84
>
> Warning: Supplied argument is not a valid File-Handle resource in
> /home2/aanr.com/www/cyber_bulletin/admin/add.php on line 84
>
> Warning: fopen("/home2/aanr.com/www/images//","wb") - Is a directory in
> /home2/aanr.com/www/cyber_bulletin/admin/add.php on line 86
> couldn't be opened (or created), please try again.
>
> Anyone know how to fix this?  I'm uploading an image from a windows hd to
a
> linux server.
>
> Tyler Longren
> Captain Jack Communications
> [EMAIL PROTECTED]
> www.captainjack.com
>
>
>
>
> --
> 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