How do I COPY a file

Get help using Construct 2

Post » Mon Jun 09, 2014 10:46 am

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...
B
37
S
15
G
7
Posts: 1,680
Reputation: 9,612

Post » Mon Jun 09, 2014 11:10 am

By default Windows prevents non-admin apps accessing system folders which may well include C:\temp. Write to the appdata folder instead.
Scirra Founder
B
395
S
233
G
88
Posts: 24,376
Reputation: 193,842

Post » Mon Jun 09, 2014 11:34 am

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
B
37
S
15
G
7
Posts: 1,680
Reputation: 9,612

Post » Mon Jun 09, 2014 3:15 pm

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.
Scirra Founder
B
395
S
233
G
88
Posts: 24,376
Reputation: 193,842

Post » Mon Jun 09, 2014 5:51 pm

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

Node
Code: Select all
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);


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"
B
11
S
2
G
1
Posts: 202
Reputation: 1,580

Post » Mon Jun 09, 2014 6:53 pm

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
B
37
S
15
G
7
Posts: 1,680
Reputation: 9,612

Post » Tue Jun 10, 2014 7:58 am

can you explain your code?? thanks
B
37
S
15
G
7
Posts: 1,680
Reputation: 9,612

Post » Tue Jun 10, 2014 6:07 pm

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.
B
11
S
2
G
1
Posts: 202
Reputation: 1,580

Post » Tue Jun 10, 2014 6:13 pm

well i still cant write a file from my ftp to my hard disk :s
B
37
S
15
G
7
Posts: 1,680
Reputation: 9,612

Post » Tue Jun 10, 2014 6:18 pm

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?
B
11
S
2
G
1
Posts: 202
Reputation: 1,580

Next

Return to How do I....?

Who is online

Users browsing this forum: Baidu [Spider], cb130felix, Kermad, Lancifer, mongoose665, piddlyPoo, yiuyiu6666 and 3 guests