473,326 Members | 2,133 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

upload a file without user having to browse or enter file name

I am trying to develop an app where: the same file, in the same place,
will be uploaded, and then processed.

Everything I can find about uploading a file, uses a form that requires
the user to either manually enter the path and file name, or to browse
for the file. I do not want that. Ideally, I want the user to click on
a link, and the server side php app does the rest. Again, the file
always has the same name, and is in the same place.

Can I load the data into the $_File array via the code? i.e.: $_File
[name] = "mydatafile.txt" ?

If there is no reasonable way around the form, can I, at least, get
have a default field appear, so that all the user has to do is verify
the file name and press the submit button?

Jul 26 '06 #1
18 2309
*** walterbyrd escribió/wrote (26 Jul 2006 08:59:59 -0700):
If there is no reasonable way around the form, can I, at least, get
have a default field appear, so that all the user has to do is verify
the file name and press the submit button?
You can use <input type="file" value="path/to/file"but it won't work in
Internet Explorer, Mozilla Firefox or Opera.

JavaScript allows certain advanced file operations when using it from your
hard disk. See these pages:

http://www.c-point.com/JavaScript/ar...JavaScript.htm
http://www.tiddlywiki.com/

Maybe you can produce a form the user can save in his hard disk.

As about PHP, it obviously has no way to reach the client computer.

--
-+ http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
++ Mi sitio sobre programación web: http://bits.demogracia.com
+- Mi web de humor con rayos UVA: http://www.demogracia.com
--
Jul 26 '06 #2
>
As about PHP, it obviously has no way to reach the client computer.
Why not? If the use can specify a file to upload, then why not just put
that in the code?

Jul 26 '06 #3

walterbyrd wrote:

As about PHP, it obviously has no way to reach the client computer.

Why not? If the use can specify a file to upload, then why not just put
that in the code?
Why? Because PHP is executed on the server, and sent to you as plain
text after completion.
To HTTP send a file using a form, that form still has to be submitted.
JS might help, check the links above.

Jul 26 '06 #4
PTM
"walterbyrd" <wa********@iname.comwrote in message
news:11*********************@75g2000cwc.googlegrou ps.com...

As about PHP, it obviously has no way to reach the client computer.

Why not? If the use can specify a file to upload, then why not just put
that in the code?
php is server side. once your page is loaded it cant actually do anything
with it unless a link or button requests another php function or script

you could always use a hidden field containing the information you would
expect for the file to be submitted.
then have a submit button that would process the form and do the upload.
you would also need to verify that the file was actually located and called
what you expected, users being what they are this might not always be the
case

Phil
Jul 26 '06 #5

PTM wrote:
php is server side. once your page is loaded it cant actually do anything
with it unless a link or button requests another php function or script
As mentioned in my original post: "I want the user to click on
a link, and the server side php app does the rest." Instead of the
user entering the path and file name, I want the path and file name as
part of the code.
you could always use a hidden field containing the information you would
expect for the file to be submitted.
then have a submit button that would process the form and do the upload.
you would also need to verify that the file was actually located and called
what you expected, users being what they are this might not always be the
case
Something like that might work. I wish I could have the default path
and file name in the box, like you can do when input="text" maybe I'll
just put the default path/file name above the box, where it can easily
cut and pasted.

Jul 26 '06 #6
PTM
"walterbyrd" <wa********@iname.comwrote in message
news:11**********************@75g2000cwc.googlegro ups.com...
>
PTM wrote:
>php is server side. once your page is loaded it cant actually do anything
with it unless a link or button requests another php function or script

As mentioned in my original post: "I want the user to click on
a link, and the server side php app does the rest." Instead of the
user entering the path and file name, I want the path and file name as
part of the code.
>you could always use a hidden field containing the information you would
expect for the file to be submitted.
then have a submit button that would process the form and do the upload.
you would also need to verify that the file was actually located and
called
what you expected, users being what they are this might not always be the
case

Something like that might work. I wish I could have the default path
and file name in the box, like you can do when input="text" maybe I'll
just put the default path/file name above the box, where it can easily
cut and pasted.
if its always going to be the same and you don't need the user to browse to
the file, then a standard input box might work ok.
but if you do need the browse, you could try using a javascript to set the
contents of the box when the page loads
Jul 26 '06 #7
"PTM" <p.********@vodafone.netwrote in message
news:bF******************@newsfe1-gui.ntli.net...
"walterbyrd" <wa********@iname.comwrote in message
news:11**********************@75g2000cwc.googlegro ups.com...
>>
PTM wrote:
>>php is server side. once your page is loaded it cant actually do
anything
with it unless a link or button requests another php function or script

As mentioned in my original post: "I want the user to click on
a link, and the server side php app does the rest." Instead of the
user entering the path and file name, I want the path and file name as
part of the code.
>>you could always use a hidden field containing the information you would
expect for the file to be submitted.
then have a submit button that would process the form and do the upload.
you would also need to verify that the file was actually located and
called
what you expected, users being what they are this might not always be
the
case

Something like that might work. I wish I could have the default path
and file name in the box, like you can do when input="text" maybe I'll
just put the default path/file name above the box, where it can easily
cut and pasted.

if its always going to be the same and you don't need the user to browse
to the file, then a standard input box might work ok.
but if you do need the browse, you could try using a javascript to set the
contents of the box when the page loads

Allthough the html 4.01 specification* suggests that a default filename
could be used in a file type input field, it's prevented in the most common
browsers simply because of user security. You just don't want a situation
where a malicious webpage has filefields pointing to your important files
and it's autosubmitted using javascript. To prevent malicious practise like
this, file fields may not have an initial value.

Of course "phishing" like this would require the malicious page to correctly
guess the locations of sensitive files, but I'm sure that if it was
possible, it wouldn't take long for someone to think of a way of exploiting
it. It's for your own safety that you cannot do this.

*) http://www.w3.org/TR/REC-html40/inte....html#h-17.4.1
FILE
Creates a file select control. User agents may use the value of the value
attribute as the initial file name.

--
"Ohjelmoija on organismi joka muuttaa kofeiinia koodiksi" - lpk
http://outolempi.net/ahdistus/ - Satunnaisesti päivittyvä nettisarjis
sp**@outolempi.net || Gedoon-S @ IRCnet || rot13(xv***@bhgbyrzcv.arg)
Jul 27 '06 #8
Following on from walterbyrd's message. . .
>I am trying to develop an app where: the same file, in the same place,
will be uploaded, and then processed.

Everything I can find about uploading a file, uses a form that requires
the user to either manually enter the path and file name, or to browse
for the file. I do not want that. Ideally, I want the user to click on
a link, and the server side php app does the rest. Again, the file
always has the same name, and is in the same place.
There is no automatic way using PHP and normal browsers.

Why not use one of the zillions of backup/file synchroniser programs to
do the upload?

Or why not maintain the file at the server end without it being saved on
the user's computer?

--
PETER FOX Not the same since the statuette business went bust
pe******@eminent.demon.co.uk.not.this.bit.no.html
2 Tees Close, Witham, Essex.
Gravity beer in Essex <http://www.eminent.demon.co.uk>
Jul 27 '06 #9

Peter Fox wrote:
Or why not maintain the file at the server end without it being saved on
the user's computer?
It might help to know what I am trying to do.

A very small warehouse just got a portable scanner. On recieving data,
the data is scanned in, then the data from the scanner is transfered to
a desktop PC. After the data is transfered to the PC, the user needs to
update the online database with that data. The database is kept online
because the clients need to view the inventory.

The process needs to be simplified as much as possible because the
warehouse workers are not that sophisticated with technology.

I don't think the online system can directly access the portable
device. Even if the device is connected, and ActiveSync is running. So
there must be a temporary stage, where a file is kept on the desktop
PC.

Jul 27 '06 #10
walterbyrd wrote:
Peter Fox wrote:

>>Or why not maintain the file at the server end without it being saved on
the user's computer?


It might help to know what I am trying to do.

A very small warehouse just got a portable scanner. On recieving data,
the data is scanned in, then the data from the scanner is transfered to
a desktop PC. After the data is transfered to the PC, the user needs to
update the online database with that data. The database is kept online
because the clients need to view the inventory.

The process needs to be simplified as much as possible because the
warehouse workers are not that sophisticated with technology.

I don't think the online system can directly access the portable
device. Even if the device is connected, and ActiveSync is running. So
there must be a temporary stage, where a file is kept on the desktop
PC.
Quite simple,actually.

Most scanners use standard serial or keyboard interface. Simply read
the data in from the scanner and update the database directly. C/C++
would be good languages for this. Depending on the data and how you
need to handle it, shouldn't be more than a few hundred LOC.

Why do the intermediate step and complicate matters?

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jul 27 '06 #11
Following on from walterbyrd's message. . .
>
Peter Fox wrote:
>Or why not maintain the file at the server end without it being saved on
the user's computer?

It might help to know what I am trying to do.

A very small warehouse just got a portable scanner. On recieving data,
the data is scanned in, then the data from the scanner is transfered to
a desktop PC. After the data is transfered to the PC, the user needs to
update the online database with that data. The database is kept online
because the clients need to view the inventory.

The process needs to be simplified as much as possible because the
warehouse workers are not that sophisticated with technology.
Tell me about it! Many years ago I was asked to set up a simple stores
system. Couldn't because none of the warehouse staff could (or could be
bothered to) read.
>
I don't think the online system can directly access the portable
device. Even if the device is connected, and ActiveSync is running. So
there must be a temporary stage, where a file is kept on the desktop
PC.
* So you've solved it. Your synch program starts at boot up. Scanner
dumps data to some file via it's comms utility. File gets beamed to
server. (Obviously there are a few WCPGWs you need to trap.)

* You could write a tiny Java program to connect to the web server then
use HTTP protocol to do a PUT See RFC 2616.

* Ask the scanner supplier for suggestions.

--
PETER FOX Not the same since the statuette business went bust
pe******@eminent.demon.co.uk.not.this.bit.no.html
2 Tees Close, Witham, Essex.
Gravity beer in Essex <http://www.eminent.demon.co.uk>
Jul 27 '06 #12
*** walterbyrd escribió/wrote (27 Jul 2006 05:42:06 -0700):
A very small warehouse just got a portable scanner. On recieving data,
the data is scanned in, then the data from the scanner is transfered to
a desktop PC. After the data is transfered to the PC, the user needs to
update the online database with that data. The database is kept online
because the clients need to view the inventory.
I'd use rsync for such purpose.

1) Install rsync server wherever you have your online database (if it's a
Linux server, it'll be already installed).

2) Create a module pointing to a temporary directory.

3) Install rsync (client) in the desktop PC.

4) Write a batch file to upload new images.

5) Create a Windows scheduled task to make the batch file execute.

As about security, rsync offers several alternatives, ranging from
passwords to user certs.

--
-+ http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
++ Mi sitio sobre programación web: http://bits.demogracia.com
+- Mi web de humor con rayos UVA: http://www.demogracia.com
--
Jul 27 '06 #13

Jerry Stuckle wrote:
Quite simple,actually.

Most scanners use standard serial or keyboard interface. Simply read
No, it doesn't work like that. The portable scanner is a PDA that has
been rigged with a laser scanner. Specifically, it's a "Symbol PPT
2800." The scanner/pda runs windows mobile. I think it connects to a
USB port. The data in the scanner is transfered with a msft application
called "ActiveSync" it is supposed to be the msft equivilent of Palm's
"HotSync."

There are a lot of advantages to using a portable scanner. It is not
tethered, you can use it anywhere without lugging a computer around.

Jul 28 '06 #14

Alvaro G. Vicario wrote:
1) Install rsync server wherever you have your online database (if it's a
Linux server, it'll be already installed).
I'm not so sure about that. The server uses Linux, but this is a
low-cost commercial service. I do not have full access to Linux. I have
PHP, MySQL, and Python. I don't even have command line access to MySQL,
I have to use MyPHPAdmin.
3) Install rsync (client) in the desktop PC.
I guess I would have to install Cygwin, or is there an rsync client for
windows?

Jul 28 '06 #15
Following on from walterbyrd's message. . .
>I'm not so sure about that. The server uses Linux, but this is a
low-cost commercial service. I do not have full access to Linux. I have
PHP, MySQL, and Python. I don't even have command line access to MySQL,
I have to use MyPHPAdmin.
Another alternative:
I'd be a bit frightened if putting all my business data on a system that
I didn't control.

How about running a local MySQL database and configuring it to replicate
on either the existing server or a 'safer' company PC. You don't need
whizzy hardware to run a web server/database and it's not difficult to
set up.

So amazingly the stores system is on http://169.255.3.3 (etc) not
www.someoddcompany/ourstores.

--
PETER FOX Not the same since the porcelain business went down the pan
pe******@eminent.demon.co.uk.not.this.bit.no.html
2 Tees Close, Witham, Essex.
Gravity beer in Essex <http://www.eminent.demon.co.uk>
Jul 28 '06 #16
walterbyrd wrote:
Jerry Stuckle wrote:
>>Quite simple,actually.

Most scanners use standard serial or keyboard interface. Simply read


No, it doesn't work like that. The portable scanner is a PDA that has
been rigged with a laser scanner. Specifically, it's a "Symbol PPT
2800." The scanner/pda runs windows mobile. I think it connects to a
USB port. The data in the scanner is transfered with a msft application
called "ActiveSync" it is supposed to be the msft equivilent of Palm's
"HotSync."

There are a lot of advantages to using a portable scanner. It is not
tethered, you can use it anywhere without lugging a computer around.
OK, I'm familiar with scanners such as that - although not that
particular one.

And yes, you can use active sync to transfer the file. But you don't
have to, either. For instance, you can put a program on the PDA which
handles the input from the scanner (which is still probably via a serial
port) to get the data, and to automatically connect with another
application on the PC to update the information.

But there is no way the server can search for files on a client machine.
Such access would be a tremendous security exposure. If you want to
automate this, you're going to have to use some method other than a
browser and web server.

And BTW - there are some very nice RF scanners out there with decent
range nowadays. You don't need the PDA and Active Sync.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jul 28 '06 #17
*** walterbyrd escribió/wrote (27 Jul 2006 20:38:46 -0700):
>1) Install rsync server wherever you have your online database (if it's a
Linux server, it'll be already installed).

I'm not so sure about that. The server uses Linux, but this is a
low-cost commercial service. I do not have full access to Linux. I have
PHP, MySQL, and Python. I don't even have command line access to MySQL,
I have to use MyPHPAdmin.
Alright, then rsync is pretty unlikely to be available.

>3) Install rsync (client) in the desktop PC.

I guess I would have to install Cygwin, or is there an rsync client for
windows?
There's an rsync client for Windows that works on top of cygwin, but you
don't need to install cygwin: cwRsync

--
-+ http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
++ Mi sitio sobre programación web: http://bits.demogracia.com
+- Mi web de humor con rayos UVA: http://www.demogracia.com
--
Jul 28 '06 #18

Alvaro G. Vicario wrote:
There's an rsync client for Windows that works on top of cygwin, but you
don't need to install cygwin: cwRsync
Thank you. That's really good to know. I love rsync for keeping my data
synced. I have a few dual booting machines on my SOHO LAN. I have used
rsync on the linux side for some time now. Hopefully now I can use it
to sync windows/linux boxes.

As for this project. I just have the user browse for the file. I
appreciate all the responses. I am learning. But, trying to keep the
user from manually entering a file name is just too difficult. I think
I will prompt with the file name, and the user can cut and paste.

Jul 29 '06 #19

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: David | last post by:
Hi, i'm using a Chilisoft ASP component - Chili!Upload I have a form as such: ___________________________ <FORM ACTION="getfile_lnx.asp" METHOD="POST" ENCTYPE="multipart/form-data">
5
by: Codeman II | last post by:
Hi there, I am building a form where the user must upload a picture and fill in his details. Now I have a problem as all of this is on the same form. How will I be able to have the Browse...
1
by: TK | last post by:
I have a file upload control to allow a user to select/upload a file to the server. They need to upload x number of files in one shot because they have to confirm that they are uploading x number...
4
by: tshad | last post by:
I am using the upload file object : <input id="MyFile" style="width:300px" type="File" runat="Server">. When I upload a file, I am saving the name of the upload file and want to be able put the...
0
by: SEMIH DEMIR | last post by:
Sitelerden birinde verilen yabancý kaynakli bir scriptti duzenledim yanlýz birseyin içinden bir turlu cýkamadým iþin aslý ilk defa persistin upload componentini kullanacam yanlýz suanki haliyle...
9
by: Wayne Smith | last post by:
I've come up against a major headache that I can't seem to find a solution for but I'm sure there must be a workaround and I would really be grateful of any help. I'm currently building a web...
7
by: pbd22 | last post by:
hi. i am having probs understanding how to grab a file being uploaded from a remote client. i am using hidden input fields for upload such as: <input id="my_file_element" type="file"...
9
by: Steve Poe | last post by:
I work for an animal hospital trying to use PHP to store an animal's dental x-rays to a file server. I can browse for the xray on the local desktop computer then click "Upload Image". This...
21
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Uploading files from a local computer to a remote web server has many useful purposes, the most...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.