[PHP] File Upload Question - Previewing .jpgs

2002-01-03 Thread Anthony Ritter

To all,
The following is a file upload question using PHP.

I am able to upload a file to my server with the following script.  (see
below)

It's in two parts - the first is a html form and the second is the php
script which takes the variable $img1_name.

However, I'd like to check if, in fact, the file was uploaded to the server.

The only way I can check this is to copy and paste the pathname that I
upoloaded in the browser's window like:

c:/Program Files/Apache Group/Apache/htdocs/reservoirphoto.jpg

When I do that the photo does load - however it loads in a paint program I
use like PaintShopPro - not as a file within the browser.

The question is this...in the textbook I'm reading (Julie Meloni - PHP Fast
and Easy - page 174), it says that:

(I can) use the File / Open Page / menu item in your web browser to
navigate through your filesystem and find the file you uploaded.

The screenshot in the book has the .jpg file photo *within* the browser
screen - not by itself in a paint program.

Can anybody assist me in this?

Thanking all in advance.
Tony Ritter

..

file://Script 1 - upload_form.html

HTML
HEAD
TITLEUpload a File/TITLE
/HEAD
BODY

H1Upload a File/H1

FORM METHOD=post ACTION=do_upload.php ENCTYPE=multipart/form-data

pstrongFile to Upload:/strongbr
INPUT TYPE=file NAME=img1 SIZE=30/p

PINPUT TYPE=submit NAME=submit VALUE=Upload File/p

/FORM

/BODY
/HTML

...
file://Script 2 - do_upload.php

?
if ($img1_name != )
 {
  copy($img1, c:/Program Files/Apache Group/Apache/htdocs/$img1_name) or
die(Couldn't copy the file.);
  }
  else
  {
  die(No input file specified);
  }
?

HTML
HEAD
TITLESuccessful File Upload/TITLE
/HEAD
BODY

H1Success!/H1

PYou sent: ? echo $img1_name; ?, a ? echo $img1_size; ?
byte file with a mime type of ? echo $img1_type; ?./P

/BODY
/HTML





-- 
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]




Re: [PHP] File Upload Question - Previewing .jpgs

2002-01-03 Thread Bogdan Stancescu

That's a browser/image type issue. If you're trying it with a JPEG image (as the
message title suggests) then it's a browser issue -- your browser doesn't handle
JPEG files due to local settings, and starts up the paint program instead. If
you're trying with some other image type (such as TIFF for instance) then this
is normal behaviour, because browsers don't generally understand other formats
than GIF, JPEG and maybe BMP and PNG, depending on the browser.

Since you seem to be using a JPEG image after all, you should check your
browser's file associations (I don't know what's the browser you're using) and
remove the association with the paint program for JPEG's.

Bogdan

Anthony Ritter wrote:

 To all,
 The following is a file upload question using PHP.

 I am able to upload a file to my server with the following script.  (see
 below)

 It's in two parts - the first is a html form and the second is the php
 script which takes the variable $img1_name.

 However, I'd like to check if, in fact, the file was uploaded to the server.

 The only way I can check this is to copy and paste the pathname that I
 upoloaded in the browser's window like:

 c:/Program Files/Apache Group/Apache/htdocs/reservoirphoto.jpg

 When I do that the photo does load - however it loads in a paint program I
 use like PaintShopPro - not as a file within the browser.

 The question is this...in the textbook I'm reading (Julie Meloni - PHP Fast
 and Easy - page 174), it says that:

 (I can) use the File / Open Page / menu item in your web browser to
 navigate through your filesystem and find the file you uploaded.

 The screenshot in the book has the .jpg file photo *within* the browser
 screen - not by itself in a paint program.

 Can anybody assist me in this?

 Thanking all in advance.
 Tony Ritter
 
 ..

 file://Script 1 - upload_form.html

 HTML
 HEAD
 TITLEUpload a File/TITLE
 /HEAD
 BODY

 H1Upload a File/H1

 FORM METHOD=post ACTION=do_upload.php ENCTYPE=multipart/form-data

 pstrongFile to Upload:/strongbr
 INPUT TYPE=file NAME=img1 SIZE=30/p

 PINPUT TYPE=submit NAME=submit VALUE=Upload File/p

 /FORM

 /BODY
 /HTML

 ...
 file://Script 2 - do_upload.php

 ?
 if ($img1_name != )
  {
   copy($img1, c:/Program Files/Apache Group/Apache/htdocs/$img1_name) or
 die(Couldn't copy the file.);
   }
   else
   {
   die(No input file specified);
   }
 ?

 HTML
 HEAD
 TITLESuccessful File Upload/TITLE
 /HEAD
 BODY

 H1Success!/H1

 PYou sent: ? echo $img1_name; ?, a ? echo $img1_size; ?
 byte file with a mime type of ? echo $img1_type; ?./P

 /BODY
 /HTML
 

 --
 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]