Frank H a écrit :
> Hi all,
> I am trying to create a function that allows me to send binary files
> from a client and have the server write it into a directory.
> I have it working right now, but it errors when I try to send a file
> greater then about 300 Kb. Any file under that size will
> transfer just fine.
> Here is the function I have on the server...
> function upload_file2($m)
> $param1 = $m->getParam(0);
> $write_file = $param1->scalarval();
> $convert_file = fopen($write_file, "rb");
> $param2 = $m->getParam(1);
> $file_name = $param2->scalarval();
> $test_write = fopen("/tmp/".$file_name, "w");
> fwrite($test_write, $write_file);
> return new xmlrpcresp(new xmlrpcval($file_name));
> $upload_file2_sig = array(array($xmlrpcBase64,$xmlrpcBase64,
> $upload_file2_doc = 'uploads a binary file';
Apart from the fact that:
- I cannot understand the intended meaning of the line $convert_file =
- I hope you trust the source of webservice calls, as you're not
validating $file_name for the presence of .. (or other similar escape)
- you could test the result of fopen before doing fwrite+fclose
- the function signature should read
- you could probably return the numbers of bytes written instead of the
it looks fine.
> I am using a Python client to send the file. I was playing around
> with a Python server to transfer files and the Python
> server does not run into any problems with file size.
> This is what I have on the python client...
> import xmlrpclib
> print("Trying to connect...")
> server_url = 'http://some_url/new_server.php';
> server = xmlrpclib.Server(server_url);
> handle = open("nova.bmp")
> file_name = "fetch_nova.bmp"
> send_file = server.sendFile(xmlrpclib.Binary(handle.read()), file_name)
> This is the error I get when trying to use the Python Client/Php
> Server combo
> Trying to connect...
> Traceback (most recent call last):
> File "testProc_client.py", line 20, in ?
> send_file = server.sendFile(xmlrpclib.Binary(handle.read()),
> File "/usr/lib/python2.3/xmlrpclib.py", line 1029, in __call__
> return self.__send(self.__name, args)
> File "/usr/lib/python2.3/xmlrpclib.py", line 1316, in __request
> File "/usr/lib/python2.3/xmlrpclib.py", line 1070, in request
> xmlrpclib.ProtocolError: <ProtocolError for
> mmodev.jpl.nasa.gov/frank/xmlrpc/demo/server/new_server.php: -1 >
Sorry, but the Python error does not help that much.
- check the php error log on the server for any hint
- check memory_limit, max_execution_time and especially post_max_size
- enable debug mode on the php server object
phpxmlrpc mailing list