Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 04-07-2012, 08:49 AM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
Uploadfile();?

Does this function work serverside?
I have a system in which you can upload files to a webserver then on the server it gets all the files by doing requesturl on a php script.
It then has a for loop which gets all the files and is supposed to upload them.
It just returns: Script: Function uploadfile not found at line 15 in script of UploadSystem.
Any idea's?

Edit: I have done some research.
My question is now: Is it possible to upload a file from a URL to a GServer?

I have tried
PHP Code:
//#CLIENTSIDE
function onCreated(){
  
Upload();
}
function 
Upload(){
  
requestText("folder""PERSONAL");
  
uploadfile("http://www.wr3ckless.net/corinthia/uploads/shop_hatshop.nw");

aswell, with no luck.
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion

Last edited by Gunderak; 04-07-2012 at 10:09 AM..
Reply With Quote
  #2  
Old 04-07-2012, 11:46 AM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
You can either let the user upload a file with selectfileforupload() (local files) or in your case you call requesturlasgamefile() on server side.
Reply With Quote
  #3  
Old 04-07-2012, 01:07 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
To clarify what Stefan said: no, and even if it did exist serverside, that's not how it's used. You're going to need to either use requesturlasgamefile, as Stefan recommended, or load the file into a variable via cURL or requestHTTP and use saveString to some folder that is in folder config. Look at my graphics uploader in the code gallery for an example.
__________________
Reply With Quote
  #4  
Old 04-07-2012, 01:36 PM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
I think I'll go with requesturlasgamefile();
I'm not on my PC atm but I take it that it works something like this?
PHP Code:
  temp.file requesturlasgamefile("http://blahblah/something/content.png");
  
temp.file.savestring("uploads/"@temp.file0); 
And is there any function in GS2 similar to PHP like move(); or move_uploaded_file?

The uploading from the webserver works, but for some strange reason when I write /find filename.nw it can't find it, and YES I have added level uploads/*.nw to the serveroptions.
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion

Last edited by Gunderak; 04-07-2012 at 02:41 PM..
Reply With Quote
  #5  
Old 04-07-2012, 04:59 PM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
Well now I'm having an issue saving the string to a file..
It worked before but now it has stopped working o.o
Here is the part that is problematic.
PHP Code:
function GetFiles(){
  
this.ply player.account;
  
temp.req requesturl("http://wr3ckless.net/corinthia/getfiles.php");
  
thiso.catchevent(req"onReceiveData""onGot");
}
function 
onGot(req){
  
temp.url "http://www.wr3ckless.net/corinthia/";
  
temp.dat req.fulldata;
  for(
temp.0temp.dat.size(); temp.++){
    
temp.file requesturlasgamefile(url@dat[f], dat[f], 0false);
    
temp.dat temp.file.fulldata;
    
temp.dat.savestring("levels/"@dat[f], 0);
    
sleep(1);
  }

It isn't creating a file, yet before it was.
And yes the control NPC has rw rights.
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
  #6  
Old 04-07-2012, 10:34 PM
Tigairius Tigairius is offline
The Cat
Tigairius's Avatar
Join Date: Jan 2007
Location: Missouri, USA
Posts: 4,240
Tigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant future
Quote:
Originally Posted by Gunderak View Post
Well now I'm having an issue saving the string to a file..
It worked before but now it has stopped working o.o
Here is the part that is problematic.
PHP Code:
function GetFiles(){
  
this.ply player.account;
  
temp.req requesturl("http://wr3ckless.net/corinthia/getfiles.php");
  
thiso.catchevent(req"onReceiveData""onGot");
}
function 
onGot(req){
  
temp.url "http://www.wr3ckless.net/corinthia/";
  
temp.dat req.fulldata;
  for(
temp.0temp.dat.size(); temp.++){
    
temp.file requesturlasgamefile(url@dat[f], dat[f], 0false);
    
temp.dat temp.file.fulldata;
    
temp.dat.savestring("levels/"@dat[f], 0);
    
sleep(1);
  }

It isn't creating a file, yet before it was.
And yes the control NPC has rw rights.
You'll need to at least tokenize req.fulldata in order to access it as an array. Here's an example:
PHP Code:
  temp.dat req.fulldata.tokenize(","); 
And even doing that won't guarantee that it'll work. It's just one thing I noticed. Also I don't know why you're using the same variable name inside of the for loop as the array that you're looping through.
__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
Reply With Quote
  #7  
Old 04-08-2012, 04:44 AM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
Now the first file will save the strings but then the rest of the files the file.fulldata returns as null o_o
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
  #8  
Old 04-09-2012, 10:37 AM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
@unknown I have tried to debug it.
No need to neg rep me, a reply would of done the job
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 11:41 AM.


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