Solved

selecting multiple files in file upload Cold Fusion CFM page

Posted on 2014-02-05
17
878 Views
Last Modified: 2014-02-07
Upload MenuUpload WindowHi,

 I have file upload page (Coldfusion .CFM ) where I can select one file at the time and below is the code. The screenshot above is what pops up when I click [Browse] button from the menu.  Is there a way that I can select multiple files by using <Shift> or <Control> key or <Control>-<A>? When I tried them, none seem to work and I can only pick one file at a time.


[UPLOAD_PHOTO1.CFM ] -----------------------------------------------------------------------

      <form action="upload_photo2.cfm" method="POST" name="frmupload" enctype="multipart/form-data">
            <input type="file" name="file_path">
            <input type="submit" name="submit_upload" value="upload">
      </form>

[UPLOAD_PHOTO2.CFM ]  -----------------------------------------------------------------------
<cfif isdefined("form.submit_upload")>
<cffile action="UPLOAD" filefield="file_path" destination="d:\home\ABC.com\wwwroot\images" nameconflict="MAKEUNIQUE">File Uploaded Successfully!
</cfif>

            <CFFORM METHOD=POST ACTION="Upload_Photo1.cfm">
                  <INPUT TYPE="Submit" Value="Upload another Picture">
               </CFFORM>

            <CFFORM METHOD=POST ACTION="AdminMenu.cfm">
                  <INPUT TYPE="Submit" Value="Return to Main Menu">
               </CFFORM>


-----------------------------------------------------------------------
0
Comment
Question by:sglee
  • 8
  • 7
  • 2
17 Comments
 
LVL 15

Accepted Solution

by:
myselfrandhawa earned 167 total points
Comment Utility
ok, first what you want to use, cfflash format type cfmultipleupload functionality of coldfusion. Then let me know, i will share the code, if you are open to some jquery solution, here is very good article by @panosms for uploading multiple files:

Here is the Links:

my Artcle: http://randhawaworld.com/?p=152

http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/Cold_Fusion_Markup_Language/A_11510-Image-ajax-upload-validate-rename-resize-using-Jquery-Coldfusion.html
0
 
LVL 52

Assisted Solution

by:_agx_
_agx_ earned 333 total points
Comment Utility
Is there a way that I can select multiple files by using <Shift> or <Control> key or <Control>-<A>?

No, not with an HTML file control. HTML file inputs do not support multiple file selection. If you need that functionality you must use a signed control, such as flash, applet, etc.

These days, most browsers support flash/applets/etc... but not all of them.  So if browser support is an issue, you may want to stick with standard html controls.
0
 

Author Comment

by:sglee
Comment Utility
File Upload 1File Upload 2File Upload 3@ myselfrandhawa
I found an article about CFFILEUPLOAD and created two following CFM Pages.

-------------------- SelectFiles.cfm --------------------------------------
<script>
    var foo = function(result)
    {
        alert(ColdFusion.JSON.encode(result));
    }
</script>
<cffileupload  
    url="uploadFiles.cfm"
    progressbar="true"
    name="myupload"
    addButtonLabel = "Add File"
    clearButtonlabel = "Clear it"
    hideUploadButton = "false"
    width=600
    height=400
    title = "File Upload"
    maxuploadsize="100"
    extensionfilter="*.jpg, *.png, *.flv, *.txt"
    BGCOLOR="##FFFFFF"
    MAXFILESELECT=100
    UPLOADBUTTONLABEL="Upload now"/>

</BODY>
------------------------ End of SelectFile.cfm ------------------------------------

--------------------- UploadFiles.cfm ------------------------
<cffile action="upload"
destination="d:\inetpub\wwwroot\ABC.COM\wwwroot\imageupload" nameconflict="makeunique"> <cfoutput>#serializeJSON({STATUS=200,MESSAGE='Passed'})#</cfoutput>
------------------------ End of UploadFiles.cfm ------------------------------------

As seen in above screenshots, I can select multiple files now (1st pic). That is good.
But when I click [Upload now], it seems to be uploading(2nd pic), but ends up in error
(3rd pic). And it never seem to execute "UploadFiles.cfm" page.

The original code of UploadFiles.cfm was as follows and I modified the destination.
<cffile action="upload" destination="#expandpath('./upload')#" nameconflict="makeunique"> <cfoutput>#serializeJSON({STATUS=200,MESSAGE='Passed'})#</cfoutput>
0
 
LVL 15

Expert Comment

by:myselfrandhawa
Comment Utility
please make sure you have disabled the debugging while you use the cffileupload functionality
0
 

Author Comment

by:sglee
Comment Utility
what do you mean by that?
0
 
LVL 52

Expert Comment

by:_agx_
Comment Utility
He means debugging set in the CF Admin:
http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Debug_02.html

When it's enabled it prints debug info at the bottom of every page. That can interfere with some operations. Either disable it in the CF Admin or use  <cfsetting showDebugOutput="false"> at the top of the script

http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7d68.html
0
 

Author Comment

by:sglee
Comment Utility
can you comment on my code in two CFM pages above as to why it fails?
0
 
LVL 52

Expert Comment

by:_agx_
Comment Utility
I notice it says 500 error. That error should be recorded in more detail in the CF logs. What do the log files say?
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

Author Comment

by:sglee
Comment Utility
I do not have access to the log file as the website is running on ISP Server.
0
 
LVL 52

Expert Comment

by:_agx_
Comment Utility
(Edit) Debugging ajax is a bit tough under the best of circumstances. Doing it on a prod machine is even harder because you don't have access to any of the necessary debugging tools. You should test it on your local dev machine first. Then you can debug to your heart's content.  On the remote server, all you can do is add a try/catch to your upload script, and send error messages to a file and/or do the same in you Application.cfc onError method.
0
 

Author Comment

by:sglee
Comment Utility
I asked ISP tech support about this problem and I am waiting to hear from them.
0
 
LVL 52

Expert Comment

by:_agx_
Comment Utility
(Edit) Ok. They could at least verify those tags are enabled and working. In the mean time, why not try it on your dev machine? (I can't test it right now) Just to verify it's not a code problem.
0
 

Author Comment

by:sglee
Comment Utility
I have CF V9 and I can install it to test.
0
 

Author Comment

by:sglee
Comment Utility
Update: ISP tech support emailed me back saying it is fixed. There were two issues:
(1) They changed the destination in CFFILE statement:
to
"D:\home\ABC.com\wwwroot\imageupload"
from
"D:\inetpub\wwwroot\ABC.com\wwwroot\imageupload"

(2) my original uploadfiles.cfm page contained HTML code and they had to remove it. I don't understand why...
------------------------------ Original uploadfiles.cfm --------------------------------
<HTML>
<HEAD>
<TITLE></TITLE>
<META name="description" content="">
<META name="keywords" content="">
<META name="generator" content="CuteHTML">
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#800080">
<cffile action="UploadAll"
destination="d:\inetpub\wwwroot\ABC.com\wwwroot\imageupload" nameconflict="makeunique"> <cfoutput>#serializeJSON({STATUS=200,MESSAGE='Passed'})#</cfoutput>
</BODY>
</HTML>

------------------------------ Revised uploadfiles.cfm  --------------------------------
<cffile action="UploadAll"
destination="d:\inetpub\wwwroot\ABC.com\wwwroot\imageupload" nameconflict="makeunique"> <cfoutput>#serializeJSON({STATUS=200,MESSAGE='Passed'})#</cfoutput>
0
 
LVL 52

Assisted Solution

by:_agx_
_agx_ earned 333 total points
Comment Utility
That makes sense. The calling page expects a valid JSON string - which you're producing by using serializeJSON (output)

This is valid JSON
{
    "STATUS": "200",
    "MESSAGE": "Passed"
}

Open in new window


But the extra HTML before and after it will cause an error because it breaks the JSON. You can test it out w/ http://jsonlint.com/

This won't validate because of the extra HTML
<HTML>
<HEAD>
<TITLE></TITLE>
<META name="description" content="">
<META name="keywords" content="">
<META name="generator" content="CuteHTML">
</HEAD>
<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#800080">
{
    "STATUS": "200",
    "MESSAGE": "Passed"
}
</BODY>
</HTML>

Open in new window

0
 

Author Comment

by:sglee
Comment Utility
Thank you for your help and I appreciate it.
0
 
LVL 52

Expert Comment

by:_agx_
Comment Utility
Welcome. Glad you solved it!
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

CFGRID Custom Functionality Series -  Part 1 Hi Guys, I was once asked how it is possible to to add a hyperlink in the cfgrid and open the window to show the data. Now this is quite simple, I have to use the EXT JS library for this and I achiev…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The purpose of this video is to demonstrate how to set up an RSS Feed on a WordPress Website. This will be demonstrated using a Windows 8 PC. Feedburner will be used for this demonstration. Go to your WordPress login page. This will look like the…
The purpose of this video is to demonstrate how to set up the permalinks on a WordPress Website. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Go t…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now