friedemann_bach Posted April 7, 2008 Share Posted April 7, 2008 I need to solve a problem concerning Python and PHP. An uploaded document has to be processed by a Python script. Up to now, this was done by calling the Python script directly from an upload form (<form ... action="../cgi-bin/upload.py">). This worked well. Now, the page has to be transfered to a new webserver that does not allow posting directly to the Python script, as the CGI-BIN folder should not be available through a php or html form, but only on server side. I tried to post the document to a PHP script that calls the Python script, e. g. by "passthru( ... /upload.py)". This works, but the uploaded document is no longer available. It seems that the post data is not passed to the Python script. Can anybody help? Link to comment https://forums.phpfreaks.com/topic/99942-solved-passing-an-uploaded-file-to-a-python-script/ Share on other sites More sharing options...
rhodesa Posted April 7, 2008 Share Posted April 7, 2008 The document should still be available. Here are the steps I would use, hopefully they will help you find your problem. -Form posts to PHP script -PHP script uses move_uploaded_file() to put the upload in a temporary location. If you want a unique filename, I would use getmypid() -If the path to the script is a relative path, use realpath() to get the absolute path the python script -Use a system command (passthru/system/exec) to call the python script, passing the absolute path to the temp file as an argument -Process the file with the python script Link to comment https://forums.phpfreaks.com/topic/99942-solved-passing-an-uploaded-file-to-a-python-script/#findComment-511105 Share on other sites More sharing options...
friedemann_bach Posted April 8, 2008 Author Share Posted April 8, 2008 Thanks for your help, Aaron, that lead me to the right track. Link to comment https://forums.phpfreaks.com/topic/99942-solved-passing-an-uploaded-file-to-a-python-script/#findComment-511879 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.