Jump to content

Send files from server to client using fetchRemote


Artix

Recommended Posts

		
		
	 function myCallback(data, errno,path)  
               if errno == 0 then  
               triggerEvent("onFileTDownload", root, "sound.mp3", data);  
		  else
              outputChatBox ('Error  '..errno)	--it return error 7, when ip == localhost returns error 1006	  
	        end		   
			   
         end	
		
		
      addEvent("onFileTDownload", false);  
      addEventHandler("onFileTDownload", root, 
              function(path,data)  
                    local file;  
                    if not fileExists(path) then file = fileCreate(path);  
                    else file = fileOpen(path); end;  
                    fileWrite(file, data);  
                    fileClose(file);                    
  
                    -- do whatever with the file ...  
              end);  
  
  function testdownload ()
    fetchRemote("http://127.0.0.1:80/testressource/sound.mp3",myCallback, "", false,':testressource/sound.mp3');  
  --[[i tried the following two examples too...
    fetchRemote("http://localhost/testressource/sound.mp3",myCallback, "", false,':testressource/sound.mp3'); 
    fetchRemote("http://localhost:80/testressource/sound.mp3",myCallback, "", false,':testressource/sound.mp3'); ]]
  end	
addCommandHandler ('tts',testdownload)  

--[[ All in the client side]]

How to solve it?

can someone help me pls

Link to comment

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...