Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

automatic file upload

Status
Not open for further replies.

lucidtech

IS-IT--Management
Jan 17, 2005
267
US
I am running a web-server that pulls information for a file located on the users hard-drive the parses the data and puts it into a database. I have my server set up with the standard CF upload code, and it works great. My question is this...

Is there a way for this to happen automatically. Like, once the user selects the file the first time, CF will automatically upload the file from their hard-drive to get the latest updates to the file. I've tried filling in the <cinfpunt type="file" value="#session.user_file#".....>
but CF doesn't fill in the file location. I've also tried using an input without the " type='file' " attribute, and CF won't accept it.. says it wasn't a file.

If I have to use javascript to do this, that's not a problem.
 
good god I hope not.

Not without a pre-installed com / active-x or java applent could you do anything like that. The security of every pc in the world would be at risk.

at any rate, CF doesn't really know what a client even is. It just answers requests from the web server, and hands back resulting html / http information

Kevin

Phase 1: Read the CFML Reference
Phase 2: ???
Phase 3: Profit!
 
The only way to have the server request anything is with cfhttp. The only way to have return a valid response is if it's running IIS or similar website management software that will respond to an HTTP request.

We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true.
 
Okay.. new question, same problem. Can I create an application using Flash Remoting that would upload the file automatically.. or at least keep track of what files they uploaded the last time they ran the program? I am very familiar with Flash Remoting, but have never using it for uploading files, and all the tutorials I find are for flash forms located on the server.
 
same type of connection issues will be present, but you'd have to ask the flash forum. i would bet no.

We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true.
 
The flash file I/O still requires user input and can not upload files automatically. The last thing in the world of the internet that you would want is a file uploaded automatically. from a client to a server. That would be the end of privacy as we know it today.

Keeping track of the files that the user manually uploaded (with a input type="file") is easy. a table of your database can store userID, filename, mimetype,filesize, date uploaded, anything you need about the file, and user.

a basic flow might be:

Upload Form (user chooses file)->
Upload Action (submit page for form)->
cffile (in submit page, saves file to specified folder)->
DB insert (saves file info to DB)

Kevin

Phase 1: Read the CFML Reference
Phase 2: ???
Phase 3: Profit!
 
The Flash Remoting program would be a self-contained file residing on the users computer. It would connect to the server via Flash Remoting.

All I really want is for the user to only have to click a button to upload a file that they will be uploading a dozen times a week, isntead of having to browse to the file everytime, since the file is about 12 folders deep on their hard-drive.
 
Well, if you know the path to the file (or can store it when they upload the file), then you can use that to automatically pre-populate the upload field every time they need to use it.

However, if they ever move the file to another location, this will break.


Hope This Helps!

ECAR
ECAR Technologies

"My work is a game, a very serious game." - M.C. Escher
 
BTW, good to see you on the forums again TruthInSatire. It's been a while.

You must not have anything to do at work today. [thumbsup2]


Hope This Helps!

ECAR
ECAR Technologies

"My work is a game, a very serious game." - M.C. Escher
 
thanks. :)

The user is going to have to go to the page... but you can automate most of it. Fill the file location and submit the page onload if a file was previously uploaded.

Code:
<cfquery name = "qGetField" datasource = "foo">
  SELECT   clientLocation
  FROM     fileLocations
  WHERE    clientUserName = '#someclientID#'
</cfoutput>
<body <cfif qGetField.recordCount>onload = "document.myForm.submit()"></cfif>>
...
...
...
<input type = "file" name = "yourFile" value = "<cfoutput>#qGetField.clientLocation#</cfoutput>">

We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true.
 
Ahhh, javascript. I knew there must be a way to do it with javascript... can be such an intrusive language sometimes.

Thank you so much to everyone who answered my questions.

 
I tried that code you posted... leaving out the javascript because I just wanted to see if it filled in the input for me... no go. Is the data there, just not seen by the user, and will be posted with the form when the javascript posts the form even though it doesn't show up on the screen?
 
I think he was giving you an example, not a working solution.


Hope This Helps!

ECAR
ECAR Technologies

"My work is a game, a very serious game." - M.C. Escher
 
Here is the code I used, in case it helps...

<cfquery name="getUserLUA" datasource="#application.database#" username="#application.db_username#" password="#application.db_password#">
SELECT user_local_lua, user_id
FROM users
WHERE user_id = #session.user_id#
</cfquery>

<form action="#cgi.script_name#?Action=Y" method="post" enctype="multipart/form-data"></cfoutput>
Source File Name:<BR>
<input type="file" name="FileContents" size="70" value="<cfoutput>#getUserLUA.user_local_lua#</cfoutput>"><br>
<input type="submit" value="Upload File">
</form>
 
I don't think value is a valid attribute of a file input - again - security issues.

Someone could build a page like the test code and point it to a know folder / file location like you quicken data and get it without you ever knowing really.

Kevin

Phase 1: Read the CFML Reference
Phase 2: ???
Phase 3: Profit!
 
That's correct, I misspoke and i apologize.

Why can't I pre-populate INPUT TYPE=FILE element?
When uploading a file, users are constantly asking if they can programmatically populate the path in an INPUT TYPE=FILE element. The fact is, users must input this file themselves by typing it in manually or using the provided Browse... button. Otherwise, it would be fairly trivial for malicious users to steal files from users' hard drives...

We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true.
 
That's correct, I misspoke and i apologize."

Meh. Just don't do it again, k? :)

I think you've helped here enough to make a mistake now and then.

Kevin

Phase 1: Read the CFML Reference
Phase 2: ???
Phase 3: Profit!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top