Hello forum,
Another question that I have is regarding sending a file created in AppGameKit through open to write.
I've found on this forum a server file for the command and I managed to put some code for transferring but i don't see the file on my server. My server is from my website, I can access it through FTP in FileZilla. Is it possible through such server, or it must a server with other capabilities?
Here is the code:
done as integer
fileID = OpenToWrite("test.txt" , 0)
WriteLine(fileID , "this is a test")
CloseFile(fileID)
cid = CreateHTTPConnection()
SetHTTPHost(cid, "0.0.0.0" , 0)
SendHTTPFile(cid , "server.php" , "" , "test.txt")
SetPrintSize(1.5)
repeat
if GetHTTPResponseReady( cid ) = 1
print (GetHTTPResponse( cid ))
else
print ( GetHTTPFileProgress( cid ))
endif
Sync()
until done = 1
CloseHTTPConnection(cid)
DeleteHTTPConnection(cid)
END
Server File:
// BEGIN PHP SCRIPT
// It is probably a good idea to do some research and add some security
// to this script as it will pretty much accept anything!
// It is important to use "myfile" as that is the index name AGK uses
// when calling SendHTTPFile()
<?PHP
if ($_FILES["myfile"]["error"] > 0){
echo "Error: " . $_FILES["myfile"]["error"] . "\n";
}
else {
echo "Upload: " . $_FILES["myfile"]["name"] . "\n";
echo "Type: " . $_FILES["myfile"]["type"] . "\n";
echo "Size: " . ($_FILES["myfile"]["size"] / 1024) . " Kb\n";
echo "Stored in: " . $_FILES["myfile"]["tmp_name"] . " \n";
if (file_exists("upload/" . $_FILES["myfile"]["name"]))
{
echo $_FILES["myfile"]["name"] . " already exists. \n\n";
}
else
{
move_uploaded_file($_FILES["myfile"]["tmp_name"], "upload/" . $_FILES["myfile"]["name"]);
echo "Stored in: " . "upload/" . $_FILES["myfile"]["name"] . " \n\n";
}
}
?>
// END PHP SCRIPT
Thank you very much!
www.alexmatei.com