Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Saving file from server to client's PC (https://forums.graalonline.com/forums/showthread.php?t=134268713)

BlueMelon 09-10-2013 03:17 AM

Saving file from server to client's PC
 
I have recently stumbled across the selectFileForDownload(str) function with no surprise of not finding much documentation.

What I want to do is download a file from the server to my PC using a save file dialog-esk UI.

This is what the function gives clientside for:
selectFileForDownload("/levels/graphics/images/test.png");
http://i.imm.io/1hFlO.png

When I click the save button, nothing happens and the function doesn't return anything.

I haven't seen this function being used anywhere either...
And the lack of documentation doesn't help.

Is there another way to download a file from the server to a client's PC?

I want to avoid uploading it to a web server and getting the client to download it from there...

I have also tried different arguments for the function with no luck.

alissalee 09-10-2013 03:49 AM

i have no answer for this. but i would love to understand this function. that would be a amazing thing

fowlplay4 09-10-2013 05:33 AM

That's a Client-RC function, and a terrible file browser.

With solely just script.

PHP Code:

function onCreated() {
  
temp.file.loadstring("level/path/to/file.png");
  
temp.data base64encode(temp.file);
  
player.triggerclient("weapon"this.name"file""file.png"temp.data);
}

//#CLIENTSIDE

function onActionClientSide() {
  if (
params[0] == "file") {
    
temp.data base64decode(params[2]);
    
temp.data.savestring(params[1], 0); // Saves to Graal/scriptfiles/Servername/file.png
    
echo("Downloaded " params[1] @ "!");
  }


Side note, just stumbled upon these functions in /scripthelp:

generatezipstring(obj) - returns string - creates a zip in memory from the array you provide like {filename, content, filename, content, ...}, save to file using str.savestring(filename, 0)
decompressfile(str, str, str, int) - returns boolean - parameters are filename, file name pattern (*), destination folder and flags (1 (keep zip paths) + 2 (keep original modification time)); unzips a file into the specified folder

BlueMelon 09-10-2013 10:56 AM

Hm, ok. I will use savestring instead.

cbk1994 09-10-2013 08:16 PM

Now slightly off topic, but re: the original post, you can see how it's used in the graphic uploader I released (and Jer modified) on the Code Gallery.


All times are GMT +2. The time now is 09:11 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.