473,626 Members | 3,031 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Best method for uploading files

113 New Member
Hi,

I'm trying to figure out the best method for uploading a number of files along with entering some data into a database using a component containing CRUD methods.

I have the following file structure:

index.cfm - Controller file
- display /
- create_update.c fm - Contains form for creating and updating a project
com /
- projects.cfc - Projects component containing CRUD methods for the project.

Previously i would have uploaded the files using the cffile function within one of the views or the controller file. What i'm thinking now is that perhaps the best place for this functionality is in the projects component. Is this correct?

Once i have sorted that, I am then left with the problem of how best to upload the files from the users point of view, should i do it all on one page where the user enters the data and chooses the files to upload and then presses submit, or should i break it up over a number of pages?

I guess what I'm asking is how would you do it?

Thanks,

Chromis
Nov 25 '08 #1
5 2627
acoder
16,027 Recognized Expert Moderator MVP
@chromis
Seems so.

Once i have sorted that, I am then left with the problem of how best to upload the files from the users point of view, should i do it all on one page where the user enters the data and chooses the files to upload and then presses submit, or should i break it up over a number of pages?
This depends on the amount of data that the user has to enter. I would say that it would be good if the user could upload on the same page. Using JavaScript, you can give the user more flexibility by letting them choose the number of files to upload.
Nov 25 '08 #2
chromis
113 New Member
Hey acoder, thanks for your reply.

I'll create a method in the projects.cfc for the uploading of the files then. There is one image and three files that will have to be uploaded, should i create a method which can handle any type of file or one which deals with the three files specifically?

Yes it seems to make sense to have it all on one page as there are only around 8 fields excluding the files. The thing i was worried about was the fact that it would take a while for the files to upload (one being a pdf and one being a movie), and that if there were errors in the validation and the form page was loaded with the errors, the how would i then best keep track of the files, that have been uploaded? should i store everything in the session? Again how would you go about structuring this?

When you say use javascript do you mean ajax? I had considered using an ajax function to call a cf upload function, so that the file would upload after the file was selected.

Thanks.
Nov 26 '08 #3
acoder
16,027 Recognized Expert Moderator MVP
@chromis
The first option would be better to give more flexibility.

The thing i was worried about was the fact that it would take a while for the files to upload (one being a pdf and one being a movie), and that if there were errors in the validation and the form page was loaded with the errors, the how would i then best keep track of the files, that have been uploaded?
You only need to upload when there are no errors, so validate before uploading. Uploads actually happen automatically and what the cffile upload tag does is move it to the correct location from the temporary location. If the cffile upload tag is not used, the file is deleted.

When you say use javascript do you mean ajax? I had considered using an ajax function to call a cf upload function, so that the file would upload after the file was selected.
I didn't mean Ajax. I was talking about flexibility in the number of file uploads, but since you have it fixed at 3, that's not needed.
Nov 26 '08 #4
chromis
113 New Member
Ok, I've structured it so the following happens:

1. User submits form
2. Submitted textual data is validated using validate method of projects component
3.
a) If there are no errors with the textual data then the upload method of the projects component is called and consequently the cffile function, the upload method returns a struct containing information on the filename and whether the upload was a success or not.
b) If there are errors the user is prompted to correct them and submit again.
4. If there are no errors returned from the upload function then the project (textual data complete with the names of the uploaded files) is entered into the database.
5. A success message is displayed.

I have opted to create a separate function for each file type as I need to use different functions depending on the file type, for instance the image file requires resizing so i'm using a third party app for that cfx_imagecr3. This allows me to organise my error messages a little bit better. It would take me a while to code a function to deal with any filetype correctly, it seems the better method conceptually but perhaps this is something i could into in the future.

This is all working now save for a problem i had the other day with the arguments of the create method in the projects component which is i want to use the correct data types with my cfqueryparam calls see this post : http://bytes.com/answers/coldfusion/...n-date-row-1-a
Nov 26 '08 #5
acoder
16,027 Recognized Expert Moderator MVP
Nice work there! Once that data type problem is dealt with, you'll be all done.
Nov 26 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

7
3993
by: lion | last post by:
I get these errors when uploading images via a web page: (the page still uploads the images but reports these errors?) Warning: fopen(D:\php\uploadtemp\php1FC7.tmp) : failed to create stream: No error in D:\webspace\me.co.uk\wwwroot\test\Live.php on line 105 Warning: Wrong parameter count for filesize() in D:\webspace\me.co.uk\wwwroot\test\Live.php on line 109
5
7829
by: Kevin Ollivier | last post by:
Hi all, I've come across a problem that has me stumped, and I thought I'd send a message to the gurus to see if this makes sense to anyone else. =) Basically, I'm trying to upload a series of files via FTP. I'm using ftplib to do it, and for each file I'm using transfercmd("STOR " + myfile) to get the socket, then uploading 4096 bytes at a time and providing status updates via a GUI interface. Finally, I close the socket, set it to...
5
5459
by: Ron Brennan | last post by:
Good afternoon. The entire task that I'm trying to achieve is to allow a user to browse and upload multiple files simultaneously, hiding the Browse button of <input> tags of type="file" and replacing it with a button of my own background color and text. The file paths I'd like displayed in a textarea and then the files uploaded at once.
10
1970
by: Rich Wallace | last post by:
Hey all, I have an XML doc that I read into a SQL Server database from an integration feed.... ----------------XML snippet ---------------- <?xml version="1.0" encoding="us-ascii"?> <!--Product data from JDEdwards--> <Root> <Root RvcDate="2004-02-03" RcvTime="14.16.03.795135">
3
1954
by: deko | last post by:
Newbie ASP.NET question: Now that I've created an ASP.NET site, how to I get it to my hosting provider? I've developed sites with Dreamweaver MX in the past - with Dreamweaver, it's very easy. The ability to link to the remote site (via FTP) is built into the IDE and all you have to do is click upload. Does Visual Studio have a similar feature? How do most people deploy their sites to a remote server from Visual Studio?
2
16795
yashg
by: yashg | last post by:
I am building a data backup application in C# using Sockets. It has a server component and a client component. The client is going to upload files to the server through TCP sockets. I've got all figured out and have been able to transfer files between client and server. Now I have some doubts about which is the best method to transfer a file? Option 1 - I use the built in Socket.BeginSendFile (I am using async calls) to transfer a file. Option 2...
0
2202
by: Raj | last post by:
Hello, I am planning to provide the Pause/Resume while uploading files. Our site is using both java applet and activex to do this. The list of selected files will be stored in an encrypted file using SHA256 (I have taken the code from: http://www.vbforums.com/showthread.php?s=&threadid=232284)
2
2330
by: =?ISO-8859-1?Q?=22=C1lvaro_G=2E_Vicario=22?= | last post by:
jodleren escribió: I haven't found the PHP manual page where such feature is documented but a few tests have shown that this behaviour changes depending on the charset parameter of the "Content-Type" HTTP header; even if I don't set an actual HTTP header and I just use a <metatag: <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> With a packet sniffer I've determined that it's not the browser who
3
5174
by: muziburrehaman | last post by:
i am looking for code in php to upload the 1 gb files. any one can please help me by sending the code....
0
8701
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8637
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8364
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6122
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5571
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4090
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2623
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1807
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1507
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.