Jump to content

Upload a image from MTA Server to Web Server


[M]ister

Recommended Posts

Hello everyone
I am trying to send a image from MTA Server to my site, however, the file is always empty... I would like to ask a help to solve this.
Thanks.

Server.lua (MTA)

function result(result,error)
    outputChatBox(tostring(result))
end

addEventHandler( "onPlayerScreenShot", root,
    function ( theResource, status, pixels, timestamp, tag )
		outputChatBox("take")
		callRemote ( "http://domain.com/idk.php", result, pixels )
    end
)

function doTakeScreenShot()
    takePlayerScreenShot( getRandomPlayer(), 320, 200 )
end
setTimer(doTakeScreenShot, 2000, 1)

idk.php (Web)

include( "mtaphpsdk_0.4/mta_sdk.php" );

$input = mta::getInput();

$myfile = fopen("newfile.jpeg", "w") or die("Unable to open file!");
fwrite($myfile, $input[0]);
fclose($myfile);

mta::doReturn(true);

Result:

kk4e5P2.jpg

 

Link to comment
  • 10 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...