[PHP] file upload question

2009-08-03 Thread seb

Hey all,

i am using move_upload function to upload files to the server, but i 
want to add a feature that will allow files to be archived that have 
been uploaded already.


so, the problem is:

i upload a file that i want to upgrade and move the old file to an 
archive directory but I want to verify the NEW file is upload BEFORE 
moving the old file (the file being uploaded might not have the same 
filename as the old file currently on the server)..


i want to move the old file only when the new file was successfully 
uploaded. something like:


if(move_uploaded_file())
{
   rename(...);
}

only one problem.. then if both files have the same name it will be 
overwritten before it moves the old one i want to save. if i move the 
old one first, there still the possibility of the new upload failing so 
i am back to square one..


i guess i can move_upload to a different directory, verify it's been 
uploaded, move the old to the archive file, then move the new file back 
to where it should be (where the archive file was)..


is that my only option? any suggestions?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] file upload question

2009-08-03 Thread Phpster





On Aug 3, 2009, at 7:04 AM, seb sebast...@triponthis.net wrote:


Hey all,

i am using move_upload function to upload files to the server, but i  
want to add a feature that will allow files to be archived that have  
been uploaded already.


so, the problem is:

i upload a file that i want to upgrade and move the old file to an  
archive directory but I want to verify the NEW file is upload BEFORE  
moving the old file (the file being uploaded might not have the same  
filename as the old file currently on the server)..


i want to move the old file only when the new file was successfully  
uploaded. something like:




only one problem.. then if both files have the same name it will be  
overwritten before it moves the old one i want to save. if i move  
the old one first, there still the possibility of the new upload  
failing so i am back to square one..


i guess i can move_upload to a different directory, verify it's been  
uploaded, move the old to the archive file, then move the new file  
back to where it should be (where the archive file was)..


is that my only option? any suggestions?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Do an check for the file before moving it

If(file_exists($filename)){
  // copy file out to archive
}

}if(move_uploaded_file())
{


}

Bastien






--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] File Upload Question

2004-07-12 Thread Vail, Warren
Perhaps this is more about HTML than PHP, but the PHP $_FILES var seems to
be set up to allow a list of files to be uploaded.  How does one get the
pop-up window to allow a user to select (ctrl-click or whatever) multiple
files in the same pop-up window?  Everything I have tried has left the user
restricted to selecting one file only.
 
thanks in advance.
 
Warren Vail
 
 


Re: [PHP] File Upload Question

2004-07-12 Thread John W. Holmes
Vail, Warren wrote:
Perhaps this is more about HTML than PHP, but the PHP $_FILES var seems to
be set up to allow a list of files to be uploaded.  How does one get the
pop-up window to allow a user to select (ctrl-click or whatever) multiple
files in the same pop-up window?  Everything I have tried has left the user
restricted to selecting one file only.
You can only select one file at a time. There's no way to change that.
--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] File Upload Question

2004-07-12 Thread xin
you might need to resolve to Java applet or other means to select more than
one files at same time. The following is an example:

http://barleypop.vrac.iastate.edu/BarleyBase/test/upload/version_05/Upload.php

yours,
xin


- Original Message - 
From: Vail, Warren [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, July 12, 2004 12:15 PM
Subject: [PHP] File Upload Question


 Perhaps this is more about HTML than PHP, but the PHP $_FILES var seems to
 be set up to allow a list of files to be uploaded.  How does one get the
 pop-up window to allow a user to select (ctrl-click or whatever) multiple
 files in the same pop-up window?  Everything I have tried has left the
user
 restricted to selecting one file only.

 thanks in advance.

 Warren Vail




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] File upload question

2004-01-21 Thread Igor Kryltsov
Hi,


If I allow multiple file uploads in my custom designed discussion board if
there any way to collect all attachments file names by reloading page and
than upload all of them on Post button (form submission)?

Displaying multiple  input type=file  on a page does not look as a
nice solution to me as amount of allowed attachments can be unrestricted.

It looks like all web based systems(yahoo mail, hotmail) upload files to
server one by one and than , I guess, they have type of pruning system which
cleans server's file system to delete files which were uploaded as a part of
compose new mail but never saved by web users.
I think it is done by looking for a files which does not have corresponding
entries in DB + timestamp on files which should be greater than session
timeout for system (if defined).

To summarize: If anyone has an idea how to collect file names of files to
upload by rePOSTing script and finally submit it to upload all files as one
go.


Thank you,


Igor

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] File upload question

2004-01-21 Thread Raditha Dissanayake
Hi Igor,
The approach taken by yahoo etc is the most popular. In your case you 
will just need to enter the message in it's entirity in the database as 
you normally would but perhaps mark it as a draft so that it does not 
become visible.

SHAMLESS PLUG: alternatively you can use rad upload at 
http://www.radinks.com/upload/ which can fit the bill including 
uploading any number of files.

all the best

Igor Kryltsov wrote:

Hi,

If I allow multiple file uploads in my custom designed discussion board if
there any way to collect all attachments file names by reloading page and
than upload all of them on Post button (form submission)?
Displaying multiple  input type=file  on a page does not look as a
nice solution to me as amount of allowed attachments can be unrestricted.
It looks like all web based systems(yahoo mail, hotmail) upload files to
server one by one and than , I guess, they have type of pruning system which
cleans server's file system to delete files which were uploaded as a part of
compose new mail but never saved by web users.
I think it is done by looking for a files which does not have corresponding
entries in DB + timestamp on files which should be greater than session
timeout for system (if defined).
To summarize: If anyone has an idea how to collect file names of files to
upload by rePOSTing script and finally submit it to upload all files as one
go.
Thank you,

Igor

 



--
Raditha Dissanayake.

http://www.radinks.com/sftp/ | http://www.raditha.com/megaupload
Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader
Graphical User Inteface. Just 150 KB | with progress bar.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] File upload question

2004-01-21 Thread Igor Kryltsov
Hi,

You recommend to allocate post id when Compose mail pressed and set
draft(boolean) = true. Than I can attach files one by one linking them to
post_id in DB.
This approach is better than mine, I think,  as files will be already linked
to post_id in DB and if post will never be submitted prune script will
delete records from DB and files from FS using same criterias (timestamp +
draft=true).
In my approach files will be stored somewhere in /draft directory and their
names have to be passed as html form parameters if later on Submit will
occur. Than they will be moved to /attch dir being linked to DB entries.


Igor


Raditha Dissanayake [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 Hi Igor,
 The approach taken by yahoo etc is the most popular. In your case you
 will just need to enter the message in it's entirity in the database as
 you normally would but perhaps mark it as a draft so that it does not
 become visible.

 SHAMLESS PLUG: alternatively you can use rad upload at
 http://www.radinks.com/upload/ which can fit the bill including
 uploading any number of files.

 all the best

 Igor Kryltsov wrote:

 Hi,
 
 
 If I allow multiple file uploads in my custom designed discussion board
if
 there any way to collect all attachments file names by reloading page and
 than upload all of them on Post button (form submission)?
 
 Displaying multiple  input type=file  on a page does not look as a
 nice solution to me as amount of allowed attachments can be unrestricted.
 
 It looks like all web based systems(yahoo mail, hotmail) upload files to
 server one by one and than , I guess, they have type of pruning system
which
 cleans server's file system to delete files which were uploaded as a part
of
 compose new mail but never saved by web users.
 I think it is done by looking for a files which does not have
corresponding
 entries in DB + timestamp on files which should be greater than session
 timeout for system (if defined).
 
 To summarize: If anyone has an idea how to collect file names of files to
 upload by rePOSTing script and finally submit it to upload all files as
one
 go.
 
 
 Thank you,
 
 
 Igor
 
 
 


 --
 Raditha Dissanayake.
 
 http://www.radinks.com/sftp/ | http://www.raditha.com/megaupload
 Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader
 Graphical User Inteface. Just 150 KB | with progress bar.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] file upload question

2003-01-24 Thread Andrew Rench
the following code:

html
body
form enctype=multipart/form-data action=?= $PHP_SELF ? 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
?php
echo $_FILES['userfile']['tmp_name'];
?
/body
/html

produces the following after upload:

/var/tmp/phplSTEVp (or php[something-or-other])

When I view that directory, it is empty.

I put togther this simple test script because I was having problems with
similar script that uses the move_uploaded_file() function.
I realize that there are many pitfalls related to filesize and uploading-
I'm testing using very small files (1-4k). I also made sure that file
uploads was enabled in the php.ini file.

Any ideas?

__
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] file upload question

2003-01-24 Thread Adam Voigt




This may just be me but I've never gotten upload to work where

the form is posting to the same page, try moving it to two pages.



On Fri, 2003-01-24 at 12:05, Andrew Rench wrote:

the following code:



html

body

form enctype=multipart/form-data action="" $PHP_SELF ? 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

?php

echo $_FILES['userfile']['tmp_name'];

?

/body

/html



produces the following after upload:



/var/tmp/phplSTEVp (or php[something-or-other])



When I view that directory, it is empty.



I put togther this simple test script because I was having problems with

similar script that uses the move_uploaded_file() function.

I realize that there are many pitfalls related to filesize and uploading-

I'm testing using very small files (1-4k). I also made sure that file

uploads was enabled in the php.ini file.



Any ideas?



__

Do you Yahoo!?

Yahoo! Mail Plus - Powerful. Affordable. Sign up now.

http://mailplus.yahoo.com



-- 

PHP General Mailing List (http://www.php.net/)

To unsubscribe, visit: http://www.php.net/unsub.php






-- 
Adam Voigt ([EMAIL PROTECTED])
The Cryptocomm Group
My GPG Key: http://64.238.252.49:8080/adam_at_cryptocomm.asc








signature.asc
Description: This is a digitally signed message part


RE: [PHP] file upload question

2003-01-24 Thread Ford, Mike [LSS]
 -Original Message-
 From: Andrew Rench [mailto:[EMAIL PROTECTED]]
 Sent: 24 January 2003 17:05
 
 the following code:
 
 html
 body
 form enctype=multipart/form-data action=?= $PHP_SELF ? 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
 ?php
 echo $_FILES['userfile']['tmp_name'];
 ?
 /body
 /html
 
 produces the following after upload:
 
 /var/tmp/phplSTEVp (or php[something-or-other])
 
 When I view that directory, it is empty.

When you upload a file, the file PHP puts it in is a temporary file -- hence the 
['tmp_name'] key -- which is your /var/tmp/php??.  Because it's a temporary file, 
PHP automatically deletes it when the script ends.  If you haven't done something with 
it in the script (such as move_uploaded_file() it), it's gone forever.

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] file upload question

2003-01-24 Thread Andrew Rench
thanks for the advice- this makes sense as to why I'm not seeing the file. I added the
move_uploaded_file() to the script to see what happens and I end up getting the 
following error:
PHP Warning: Unable to move '/var/tmp/phpfcwVyC' to 
'/usr/local/etc/httpd/htdocs/blast/images' in
/usr/local/etc/httpd/htdocs/blast/upload_test2.php on line 10

Am I setting the path wrong? Should it be relative to the 'upload_test2.php' file?

thanks

--- Ford, Mike   [LSS] [EMAIL PROTECTED] wrote:
  -Original Message-
  From: Andrew Rench [mailto:[EMAIL PROTECTED]]
  Sent: 24 January 2003 17:05
  
  the following code:
  
  html
  body
  form enctype=multipart/form-data action=?= $PHP_SELF ? 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
  ?php
  echo $_FILES['userfile']['tmp_name'];
  ?
  /body
  /html
  
  produces the following after upload:
  
  /var/tmp/phplSTEVp (or php[something-or-other])
  
  When I view that directory, it is empty.
 
 When you upload a file, the file PHP puts it in is a temporary file -- hence the 
['tmp_name']
 key -- which is your /var/tmp/php??.  Because it's a temporary file, PHP 
automatically
 deletes it when the script ends.  If you haven't done something with it in the 
script (such as
 move_uploaded_file() it), it's gone forever.
 
 Cheers!
 
 Mike
 
 -
 Mike Ford,  Electronic Information Services Adviser,
 Learning Support Services, Learning  Information Services,
 JG125, James Graham Building, Leeds Metropolitan University,
 Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
 Email: [EMAIL PROTECTED]
 Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 


__
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] file upload question

2003-01-24 Thread Mark Heintz PHP Mailing Lists

You have to include a filename along with the path when you're using
move_uploaded_file(); if you're only specifying
'/usr/local/etc/httpd/htdocs/blast/images' as your destination string, php
is trying to create a file named 'images' in
'/usr/local/etc/httpd/htdocs/blast'.  If there's still a problem,
the user that your webserver (and therefore php, in most cases) runs as
may not have write permission to the directory you're trying to move to.
Make sure the webserver can write to the destination directory.

mh.


On Fri, 24 Jan 2003, Andrew Rench wrote:

 thanks for the advice- this makes sense as to why I'm not seeing the file. I added 
the
 move_uploaded_file() to the script to see what happens and I end up getting the 
following error:
 PHP Warning: Unable to move '/var/tmp/phpfcwVyC' to 
'/usr/local/etc/httpd/htdocs/blast/images' in
 /usr/local/etc/httpd/htdocs/blast/upload_test2.php on line 10

 Am I setting the path wrong? Should it be relative to the 'upload_test2.php' file?

 thanks

 --- Ford, Mike   [LSS] [EMAIL PROTECTED] wrote:
   -Original Message-
   From: Andrew Rench [mailto:[EMAIL PROTECTED]]
   Sent: 24 January 2003 17:05
  
   the following code:
  
   html
   body
   form enctype=multipart/form-data action=?= $PHP_SELF ? 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
   ?php
   echo $_FILES['userfile']['tmp_name'];
   ?
   /body
   /html
  
   produces the following after upload:
  
   /var/tmp/phplSTEVp (or php[something-or-other])
  
   When I view that directory, it is empty.
 
  When you upload a file, the file PHP puts it in is a temporary file -- hence the 
['tmp_name']
  key -- which is your /var/tmp/php??.  Because it's a temporary file, PHP 
automatically
  deletes it when the script ends.  If you haven't done something with it in the 
script (such as
  move_uploaded_file() it), it's gone forever.
 
  Cheers!
 
  Mike
 
  -
  Mike Ford,  Electronic Information Services Adviser,
  Learning Support Services, Learning  Information Services,
  JG125, James Graham Building, Leeds Metropolitan University,
  Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
  Email: [EMAIL PROTECTED]
  Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211


 __
 Do you Yahoo!?
 Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
 http://mailplus.yahoo.com

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] file upload question

2003-01-24 Thread Andrew Rench
When you say you need to include a filename, do you mean the 
$_FILES['userfile']['tmp_name'] or
the variable name identified in the input tag? (name=userfile)

--- Mark Heintz PHP Mailing Lists [EMAIL PROTECTED] wrote:
 
 You have to include a filename along with the path when you're using
 move_uploaded_file(); if you're only specifying
 '/usr/local/etc/httpd/htdocs/blast/images' as your destination string, php
 is trying to create a file named 'images' in
 '/usr/local/etc/httpd/htdocs/blast'.  If there's still a problem,
 the user that your webserver (and therefore php, in most cases) runs as
 may not have write permission to the directory you're trying to move to.
 Make sure the webserver can write to the destination directory.
 
 mh.
 
 
 On Fri, 24 Jan 2003, Andrew Rench wrote:
 
  thanks for the advice- this makes sense as to why I'm not seeing the file. I added 
the
  move_uploaded_file() to the script to see what happens and I end up getting the 
following
 error:
  PHP Warning: Unable to move '/var/tmp/phpfcwVyC' to 
'/usr/local/etc/httpd/htdocs/blast/images'
 in
  /usr/local/etc/httpd/htdocs/blast/upload_test2.php on line 10
 
  Am I setting the path wrong? Should it be relative to the 'upload_test2.php' file?
 
  thanks
 
  --- Ford, Mike   [LSS] [EMAIL PROTECTED] wrote:
-Original Message-
From: Andrew Rench [mailto:[EMAIL PROTECTED]]
Sent: 24 January 2003 17:05
   
the following code:
   
html
body
form enctype=multipart/form-data action=?= $PHP_SELF ? 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
?php
echo $_FILES['userfile']['tmp_name'];
?
/body
/html
   
produces the following after upload:
   
/var/tmp/phplSTEVp (or php[something-or-other])
   
When I view that directory, it is empty.
  
   When you upload a file, the file PHP puts it in is a temporary file -- hence the
 ['tmp_name']
   key -- which is your /var/tmp/php??.  Because it's a temporary file, PHP 
automatically
   deletes it when the script ends.  If you haven't done something with it in the 
script (such
 as
   move_uploaded_file() it), it's gone forever.
  
   Cheers!
  
   Mike
  
   -
   Mike Ford,  Electronic Information Services Adviser,
   Learning Support Services, Learning  Information Services,
   JG125, James Graham Building, Leeds Metropolitan University,
   Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
   Email: [EMAIL PROTECTED]
   Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211
 
 
  __
  Do you Yahoo!?
  Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
  http://mailplus.yahoo.com
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 


__
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] file upload question

2003-01-24 Thread Jason Wong
On Saturday 25 January 2003 06:34, Andrew Rench wrote:
 When you say you need to include a filename, do you mean the
 $_FILES['userfile']['tmp_name'] or the variable name identified in the
 input tag? (name=userfile)

ANY filename which makes sense to you, so most likely the latter.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *

/*
You have been in Afghanistan, I perceive.
-- Sir Arthur Conan Doyle, A Study in Scarlet
*/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




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




[PHP] File Upload Question...

2001-12-25 Thread Anthony Ritter

Merry Christmas everybody.

I am using MS Windows 98 with Apache and following an example in Julie
Meloni's PHP - Fast and Easy (Chapter 10) in which she describes file
uploading using PHP on page 168-174.

She has two files:
1) an html form to receive the input from the user for the file to be
uploaded
2) a .php script to accept the variable and use the copy() function.
.

The scripts are as follows:
(html form)

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

(.php script)

?
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
..

My questions:
I am able to upload a file from My Documents  to the Apache server however
in her book, she describes that the user can verify that the file was
uploaded to the server by going to:

File/ Open Page / in ones web browser to navigate through their filesystem
to
find the file that was uploaded.  There is a screenshot in the book that
shows the .jpeg file on the screen with the browser at:
file:///C/Apache/htdocs/blahblah.jpg

I can't seem to verify that the file exists using this method.

The only way I can verify that the file was indeed uploaded is to go into
the folder within Apache that was specified in the path and check there.

*How can I check by going through the browser window?*

Next question:

When I check that the file was uploaded, the file is saved in:
C:/Program Files/Apache Group/Apache/htdocs/$img1_name

as the *regular *.jpeg name I originally gave it - not the variable - $img1.

Is this correct? Or, should the file be saved as:
img1?

And the last question:
This is the line I received upon sending the file:

You sent: KewpieSmall.jpeg, a 3127 byte file with a mime type of
image/pjpeg.

In her book, it says:
image/jpeg.

What is:
image/pjpeg.?

Many thanks and best wishes to all for a happy and healthy new year.
Tony Ritter






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

2001-04-05 Thread Renze Munnik

Joe Stump wrote:
 
 I'm in the habit of putting all my form variables into an array (ie:
 input type="text" name="f[firstname]" value="? echo $f['firstname']; ?") so
 that I have a nice little package to pass to functions. My question is can you
 put files into those as well? If so how does it handle the $file_name and
 $file_size variables PHP creates?
 
 --Joe
 
 /**\
  *Joe Stump - PHP/SQL/HTML Developer  *
  * http://www.care2.com - http://www.miester.org - http://gtk.php-coder.net   *
  * "Better to double your money on mediocrity than lose it all on a dream."   *
 \**/
 
 --
 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]


Yes. You can just make a file-upload element in your form. E.g.:
INPUT type="file" name="f[myFile]"

In your "result-page" you can use the uploaded file pretty
straightforward:
temp-filename: $f[myFile]
filename: $f_name[myFile]
size: $f_size[myFile]
mimetype: $f_type[myFile]
-- 

* RzE:

***
**  Renze Munnik
**
**  E: [EMAIL PROTECTED]
**  M: +31 6 218 111 43
***

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

2001-04-05 Thread Yasuo Ohgaki

Yes. Refer to PHP Manual. There is description for that.

--
Yasuo Ohgaki


"Joe Stump" [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 I'm in the habit of putting all my form variables into an array (ie:
 input type="text" name="f[firstname]" value="? echo $f['firstname']; ?")
so
 that I have a nice little package to pass to functions. My question is can you
 put files into those as well? If so how does it handle the $file_name and
 $file_size variables PHP creates?

 --Joe




/**\
  *Joe Stump - PHP/SQL/HTML Developer
*
  * http://www.care2.com - http://www.miester.org - http://gtk.php-coder.net
*
  * "Better to double your money on mediocrity than lose it all on a dream."
*

\**/

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