PDA

View Full Version : File Upload ASP.net 2.0



sunsmile
July 24th, 2007, 09:59 AM
Hi EveryBody,
I am going through file reference API(File Upload) and wondering whether it is possible to log an entry in database, just before the upload started or the upload button is clicked. Any help here is greatly appreciated.

CarlLooper
July 24th, 2007, 03:42 PM
Until a browse call returns with success no propertys of the file are available (as the file has yet to be selected). But once this call succeeds (which is prior to upload being called), you have access to the available propertys of the file and can write such info to a database. But you would probably want to wait until upload was called (and completed) before doing this as the user might want to cancel an upload and you'll have spurious info in your database.

Carl

Note that browsing happens outside of the flash sandbox - so you have no access to anything occuring during a browse. It is only when the user has selected a file does information (about the file) become available.

sunsmile
July 24th, 2007, 06:37 PM
Carl,
Thanks for you reply. Can you provide me with the snippet of code which does the call to database from flash. Yeah... it would be good idea to log when the upload is done completely. But here our requirement (from manager)is to log as soon as the upload button is clicked.

Any furthur comments or suggestions here are welcome.

Thank You Very Much.

CarlLooper
July 24th, 2007, 10:12 PM
Coding how data is sent to your database is entirely dependant on how your database is implemented and how it expects to recieve data.

Generally speaking you'll put code in your button click handler. When a user selects a file in the file browser the FileReference object will be populated with the file info (which is not much info at all by the way). When your upload button is clicked your button click handler code will get the data out of the FileReference object and send it to your database in whatever format your database is expecting. You'll need to make sure the data is valid (which it won't be if the user has cancelled the file browse)

As mentioned - I can't give you any examples of how you send data to your database without knowing how your database has been implemented, but generally speaking you would just look at how your database is "normally" used and ensure your Actionscript addresses the database in the same way.

Carl