How do I COPY a file

0 favourites
  • 12 posts
From the Asset Store
Source File, music and art pack for Android Negotiator
  • hi again the same question maybe more structured, so i got no answer about this problem, and still looking for a solution.

    Im trying to COPY a file fro mmy ftp to a folder for ex: "C:\temp"

    so i put a buton "download" and i added ajax+nodewebkit in my app.

    the actions i use are:

    Onclicked -> AJAX -> Request "url+filename" the file is an empty file named "test" without extension.

    AJAX -> Ajaxlastdata completed -> Nodewebkit -> Write AJAXlastdata to file "C:\temp"

    i also tried Write AJAXlastdata to file "C:\temp\test"

    and i tried a lot of stuffs but nothing works...

    ajax or nodewebkit cant copy file from ftp to hdd??? why...

  • By default Windows prevents non-admin apps accessing system folders which may well include C:\temp. Write to the appdata folder instead.

  • well i tried creating a folder C:\test but that also change nothing, it looks impossible to copy a file from an ftp to the hdd :s and also i trid to put the file inside the app and extract that fiel to the hdd, but its impossible :s

  • All folders in the C: drive require admin permission to access under default Windows settings. Your app is only guaranteed to have access to the appdata folder.

  • Worked for me, can you send the file you want to download out as text?

    Node

    var fs = require('fs'), 
           http = require('http'), 
           path = require('path'), 
           ct = {'Content-Type:':'text/plain'},
    
    //The file to send
          file = fs.readFileSync(path.resolve('.\\DOCS\\','doc.txt'));
    	
    http.createServer(function (req, res) {switch(req.url.toLowerCase()){
      	case '/route': res.writeHead(200,ct); res.end(file.toString()); break;
      	default : res.writeHead(404,ct); res.end("404"); break;
    }}).listen(1337);
    [/code:3axab91t]
    
    Construct
    
    On start of layout : Ajax Request "http:// ... url/route" - "tag 'M'"
    On "M" complete Node-Webkit Write Ajax.lastdata to file "C:\test\filename.txt"
  • well my file is just here: http://www.mattepainting.be/test.doc

    where i have to pur your code???? the rest of my app is good

  • can you explain your code?? thanks

  • Sorry I couldn't answer sooner. The first part is just a server script for node js to test with you can ignore it ;

    In short what it's doing - > is reading a file and then starting a new server instance. Any incoming requests with url '/route' are served the file with content type plain text else a 404 notice.

    Do the same thing in php or w.e else and it should work? Good luck, hope you figure it out.

  • well i still cant write a file from my ftp to my hard disk :s

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I unno, I had the test folder and text file created ahead of time. Dump your response text to a text object so you know you got it. After saving to disk with AJAX.lastdata the file contents aren't changed?

  • well in my app i just have one button, download and when i do

    Onclicked -> AJAX -> Request "url+filename".

    AJAX -> Ajaxlastdata completed -> Nodewebkit -> Write AJAXlastdata to file "C:\temp\test.doc"

    bu that does nothing at all :s

  • i found this in node js.

    can someone help me with that ?

    Ftp.get(remotePath, localPath, callback)

    Stores the remote file directly in the given local path.

    ftp.get('remote/file.txt', 'local/file.txt', function(hadErr) {

    if (hadErr)

    console.error('There was an error retrieving the file.');

    else

    console.log('File copied successfully!');

    });

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)