Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FTP Using Javascript / AJAX 5

Status
Not open for further replies.

1DMF

Programmer
Jan 18, 2005
8,795
GB
Is it possible to create an FTP client using Javascript?

I need to get a web page to connect to a webserver and upload some large files via FTP protocol.

MIME encoded POST method via HTTP is not an option.

So am looking for an alternative, I'd like to write something myself, as it's for a specific function, so full FTP features not needed.

I'm getting to the point where I might have no choice but to use FLASH or JAVA applets, but was hoping there was some way of using the FTP protocol and Javascript / AJAX to write the webapp.

Thoughts?



"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!
 
you'll need to use some sort of a scripting language..here's an example with PHP



--------
GOOGLE is a great resource to find answers to questions like "how do i..."

If you don't know exaclty what you want to do or what to search on, try Google Suggest: --------
I have recently been semi-converted to ensuring all my code (well most of it) works in both javascript and non-javasc
 
Hi

I think 1DMF forgot to mention that he need a functional improvement not fanciness.

Anyway, that "AJAX" upload is nothing but setting the [tt]form[/tt]'s [tt]target[/tt] to a hidden [tt]iframe[/tt] so it not replaces the original document, and sets some event handlers to get a knock on completion. But it is nothing but an ordinary [tt]form[/tt] submitted with HTTP POST method. About which the OP wrote :
1DMF said:
MIME encoded POST method via HTTP is not an option.

Feherke.
 
lol : cheers Feherke.

I've found some stuf using ASP and an ActiveX component from ChillKat, from what I can tell with further scrutiny it uses HTTP (but it is supose to use inet.dll the point of the ActiveX component) and I still cant' get my head round it's implementation.

from the example it seems all it will do is FTP from one server to another NOT local client machine!

Half a day wasted chasing my tail and counting.

I can't beleive something which seems so simple is so difficult to achieve.

I even found a JS version, but all it did was load two windows side by side and then tried to access c:\ , so it just JS errored with 'Access Denied' , now there's a suprise!

Why is this so hard to achieve, I guess internet security.

I'm getting close to just saying sod it! writing it in VBScript and having them download it and run it via the windows scripting host, don't know what else to do other than plug direct into inet.dll via VBS



"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!
 
If it's windows-bounded, an Activex with a command line invocation can do the trick

Cheers,
Dian
 
That's what I thought but I don't seem to be able to find a forum to post in who can help with this.

All this I thought would be part of the Windows API , but i've just been told off for posting in that forum?

So where do I go to learn how to create an active X component, how you get the browser to install it and the browser to use it?

For the moment It looks more like i'm gonna give up trying to do this webapp wise as I've just found out I can package MS access apps to run standalone with out MS Access installed on client.

I can write a nice userfriendly app they can download and run that way, I have already written FTP functionality in MS Access using the windows API and inet.dll so , that's looking more and more like the best solution.

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!
 
So where do I go to learn how to create an active X component

presumably the forum for whatever language you wish to write it in, e.g. C, C++, etc.

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

Dan's Page [blue]@[/blue] Code Couch:
Code Couch Tech Snippets & Info:
 
I guess it's VB/VBS then , can you create a VBS script and turn it into ActiveX ? does it still use WSH?

It's hard to know which way to go when you don't have a solid starting point :-(

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!
 
Code:
var oShell = new ActiveXObject("Shell.Application"); 
oShell.Run ("ftp whatever");

Cheers,
Dian
 
Hi

While an Explorer-only solutions is Ok, this could be the cheapest alternative :
HTML:
<html>
<head>
<title></title>
</head>
<body>
<form action="" method="post" enctype="multipart/form-data">
Upload your file<br>
<input type="file" name="smallfile"> ( Ok for smaller files )<br>
<iframe src="ftp://example.com/"></iframe> ( Drag &amp; drop big files here )<br>
<input type="submit">
</form>
</body>
</html>
Explorer does an anonymous FTP put when the URL is ftp:// and a file is dropped over.

Note, that this way the script which will process the submitted [tt]form[/tt] will not know the name of the file uploaded through FTP. So either the user will have to specify its name, or the script will have to figure out based on the file date and the uploader IP address parsed out from the FTP server's log.


Feherke.
 
thanks for the inpu guys...

vickvirk -> all very well and good but the MS site says..
Requirements
The following list outlines the recommended hardware, software, network infrastructure, and service packs that you need:
Visual Basic .NET or Visual Basic 2005
This article assumes that you are familiar with the following topics:
Visual Basic .NET or Visual Basic 2005
ActiveX
I have MS Access!

Thanks ferherke, but I cannot totally force IE , I know some use FireFox. and forcing specific browser use is not considered acceptable in a web app, inhouse you can get away with it , but not for external joe public members!

I'm going down the HTTP route and trying my hardest to configure the server to handle it and see how we go.

All this has made me sign up to do a Diploma in Computing/ IT and my first core modue is Java and Obeject Orientation.

I'm fed up of my knowledge and asshole of an employer holding me back when I need to achieve stuff, so one day, i'll write my own bloody webapp intergrated FTP clienty thing ;-)

---------------------------------------
Dian are you serious it's as simple as that ?

var oShell = new ActiveXObject("Shell.Application");
oShell.Run ("ftp whatever");

Man two days and 10 threads in different forums , to come up with 2 lines of script [lol]

OK, so how to use the object to to do a progress meter and know when the upload has finished...

I take it i'm in the right forum as that code is JavaScript or do I need to go in a different forum to interact with the activex object?

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!
 
Some considerations:

- That's an IE-specific not-specially-good-workaround
- It will open a dos window that will use resident ftp command to upload the file
- AFAIK, there's no control about it

If you want a progress bar, I'm afraid you will need an http upload with some server-side processing and ftp from there.

Btw, my star for feherke. Nice idea

Cheers,
Dian
 
I thought ActiveX was Windows platform specific not browser, dang!

Right HTTP upload it is, so now all I need to know is how you check file size prior to upload!

I'll use AJAX to do the progress thingy.

Stars all round :)

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!
 
Hi

1DMF said:
I need to know is how you check file size prior to upload!
I see nobody else reacted to this, so I suppose nobody else knows a better answer.

As far as I know, there is no way to find it out before starting the upload.

But the AJAX upload progress solutions usually get file size information too, so you will know it immediately after submitting started.

One way would be to do an ugly trick : when the user clicks Submit, first set the [tt]form[/tt] [tt]action[/tt] to, let us say, getfilesize.php. That script would immediately cancel the upload, but in that moment it would already know the file size. With some AJAX your JavaScript will get that file size, and if is acceptable, will set the [tt]form[/tt] [tt]action[/tt] to the real one and submit again.

Brr ! Sounds abit complicated.


Feherke.
 
But the AJAX upload progress solutions usually get file size information too, so you will know it immediately after submitting started.
how, until the file is uploaded how do you know how big the file is?

I'm confused.com!



"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top