Apache Python: Uploaded binary file not able to read

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Apache Python: Uploaded binary file not able to read

Postby Ashwin » 25. January 2015 11:05

I am using apache server running under XAMPP control panel. In that I configured python script for web service. In that I tried to upload a xls file, where the uploaded file is always been written to disk as binary dump file of 49.2KB. Instead i tried to upload html text file, it works fine with simple text files. I even tried to upload a .doc file format. Even that the behavior remains the same. Please help me on this issue.

For making python to work with apache, I changed the following http.conf file line:
Code: Select all
AddHandler cgi-script .cgi .pl .asp .py

I am using the following code snippets for doing the above process:

Code: Select all
<form name='getXlFileForm' action='reader.py' method='post' enctype='multipart/form-data'>
    <input type='file' name='xlFileFromForm' />
    <input type='submit' value='Upload' />

Code: Select all
requestForm = cgi.FieldStorage()
uploadedFiles = requestForm['xlFileFromForm']

if uploadedFiles.file:
    temFile = tempfile.NamedTemporaryFile(mode='w+b',prefix=outputDir, suffix='.xls', delete=False)
    #inFileName = os.path.basename(uploadedFiles.filename)
    uploadedName = os.path.basename(uploadedFiles.filename)
Posts: 1
Joined: 25. January 2015 10:43
Operating System: Windows

Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 62 guests