473,508 Members | 2,303 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.cfm - 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 2621
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
3979
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...
5
7815
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...
5
5448
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...
10
1952
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"?>...
3
1942
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...
2
16788
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...
0
2180
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...
2
2311
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...
3
5157
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
7123
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7382
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...
1
7042
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...
0
5627
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5052
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...
0
4707
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...
0
3181
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1556
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 ...
1
766
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.