• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Progress bar to show the status of file upload to ftp server

New Here ,
May 19, 2023 May 19, 2023

Copy link to clipboard

Copied

Hi,

I am trying to upload file to ftp server with CFFTP tag. the code that i am using is:

<cfset variables.uploadedFileServerName = "TestUploadFile" & "/" & "#fileName#" />
<!---<cfset fileName =  uploadResult.serverfile/>--->
 
<cfftp connection="session.ftpConn"
action="open"
server="uploaduat.flexnetoperations.com"
username="some user"
password="password"
stoponerror="Yes"
timeout="90000">
Did it open connection? <cfoutput>#cfftp.succeeded#</cfoutput><br />
<cfif cfftp.succeeded>
 
<cfftp connection = "session.ftpConn"
action = "PutFile"
localFile="#form.FileContents#"
remoteFile="#variables.uploadedFileServerName#"
stoponerror="Yes"
passive = "Yes"
timeout="90000">
<P>Did it succeed? <CFOUTPUT>#CFFTP.Succeeded#</CFOUTPUT>
<cfif CFFTP.Succeeded>
<P>Close the connection:
<CFFTP ACTION="close"
CONNECTION="session.ftpConn"
STOPONERROR="Yes">
<P>Did it succeed? <CFOUTPUT>#CFFTP.Succeeded#</CFOUTPUT>
<cfset form.FileContents = ""/>
<cfset fileId = URL.fileId/>
<script type="text/javascript" language="JavaScript">
    <cfoutput>
 
Is there a way to show the progressbar to show the progress of file upload to ftp server to the user? 
 
Thanks in advance

Views

442

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 22, 2023 May 22, 2023

Copy link to clipboard

Copied

You know roughly how long the process is supposed to take: max 90 000 seconds. So you could use cfprogressbar.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 23, 2023 May 23, 2023

Copy link to clipboard

Copied

Hi @BKBK  thanks for replying. but the issue is the progressbar should show the progress of uploading the files, there would be some smaller files it would take much less time to upload. so basically it should show the upload of the file.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 24, 2023 May 24, 2023

Copy link to clipboard

Copied

What is your ColdFusion version and update level?

 

As far as I know, ColdFusion no longer has custom progress-bars for simultaneous file-uploads. Such tools, based on Javascript and Flash, have been deprecated. You will have to build your own.

 

Search the web for possibilities. When you find one that meets your needs, return to the forum and we can look into it together. That's the only suggestion I can think of at the moment.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 25, 2023 May 25, 2023

Copy link to clipboard

Copied

Hi @BKBK , I can show the progress bar and send bytes thorugh java script with this code:

function uploadFile(){
 
var file = _("FileContents").files[0];
 
var formdata = new FormData();
formdata.append("FileContents", file);
var ajax = new XMLHttpRequest();
ajax.upload.addEventListener("progress", progressHandler, false);
//ajax.addEventListener("load", completeHandler, false);
ajax.addEventListener("error", errorHandler, false);
ajax.addEventListener("abort", abortHandler, false);
ajax.open("POST", "view/UploadFileToFileDesc.cfm");
ajax.send(formdata);
 
}
function progressHandler(event){
//_("loaded_n_total").innerHTML ="Uploaded "+event.loaded+" bytes of "+event.total;
var percent = (event.loaded / event.total) * 100;
_("progressBar").value = Math.round(percent);
_("status").innerHTML = "(Uploaded "+event.loaded+" bytes of "+event.total+")"+Math.round(percent)+"% uploaded... please wait";
}
function completeHandler(event){
$(document).ready (function () {
_("status").innerHTML = event.target.responseText;
_("progressBar").value = 100;
});
}
function errorHandler(event){
_("status").innerHTML = "Upload Failed";
}
function abortHandler(event){
_("status").innerHTML = "Upload Aborted";
}
 
But the issue here is how do i send the bytes data(File Content) to ftp server via coldfusin cfftp tag. 
<cfftp connection = "session.ftpConn"
transferMode = "auto"
action = "PutFile"
localFile="#localFile#"
remoteFile="#variables.uploadedFileServerName#"
stoponerror="Yes"
passive = "Yes"
timeout="90000">

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 27, 2023 May 27, 2023

Copy link to clipboard

Copied

I don't quite understand the link you're making between upload and FTP . The one is <cffile action="upload"> via a form, whereas the other is <cfftp action="putFile">.

 

I expected the FTP progressbar to do something like:

  • Start by determining the size of the file to be PUT or GET.
  •  Intermittently calculate the number of bytes that have been written or read. Then display the number as a percentage of the file-size.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 27, 2023 May 27, 2023

Copy link to clipboard

Copied

Something else. A thought just occurred to me.

 

Do I understand correctly that the process involves <cffile action="upload">, followed by <cfftp action="putFile">? If so, why?

Why not just <cffile action="upload">?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 31, 2023 May 31, 2023

Copy link to clipboard

Copied

Hi @BKBK  the process involves 

<cfftp connection="session.ftpConn"
action="open"
<cfftp connection = "session.ftpConn"
action = "PutFile"
first i am opening the ftp connection and then putting file on ftp server.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 31, 2023 May 31, 2023

Copy link to clipboard

Copied

The Javascript you shared seems to be for file upload, not for FTP.

In any case, assuming you have access to the servers, why don't you just use <cffile action="upload">?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 31, 2023 May 31, 2023

Copy link to clipboard

Copied

Hi @BKBK , not sure how we can put fto files through  <cffile action="upload">.  How can we give server details , username, password for the ftp server in this tag ?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 31, 2023 May 31, 2023

Copy link to clipboard

Copied

Hi @Akash299451589siy ,

I am not recommending the one process or the other, at least not yet. I'm just trying to understand your scenario and the result you want.

 

As I said earlier, I cannot see how we can use the above "Upload" Javascript as FTP progress-bar. What I would do is to look for code that is better suited to FTP. Either front-end (e.g. Javascript) or back-end (e.g. Java or CFML).

 

It could also be that I am missing the point. If so, I would be grateful if you could correct me.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 31, 2023 May 31, 2023

Copy link to clipboard

Copied

LATEST

I thought this thread mentioned using CFFTP to move very large files, maybe videos? I don't see that in here though, so maybe I'm getting threads confused. Just to warn you, CF is not good at that because it's designed for a completely different purpose: running web applications. To do that effectively, CF creates a thread pool at startup, and can't increase or decrease that number as it runs. If you set this to, for example, five, it will create five threads in the pool and if you have more than five requests it'll queue those until there's a free thread. Normally, you might not notice this because those threads will quickly do their work and take the next requests from the queue. But if you have a long-running request - like you might easily get with CFFTP - it'll keep that thread until it's done and the queue will just get larger and larger. So anyway, that's a thing.

 

As for monitoring the time a CFFTP request takes, there's nothing built into CF to do that for you. You can't find out within CF how much of a specific CFFTP operation has been completed, as far as I know. If I'm right about this, you'd have to do your ftp from a different language that can report bytes sent, and invoke that ftp program from within CF.

 

Dave Watts, Eidolon LLC

Dave Watts, Eidolon LLC

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation