Hi all,<br>I want to upload a file from python to php/html form using urllib2,and my code is below<br><br>PYTHON CODE:<br>import urllib<br>import urllib2,sys,traceback<br>url='<a href="http://localhost/index2.php">http://localhost/index2.php</a>'<br>
values={}<br>f=open('addons.xcu','r')<br>values['datafile']=f.read() #is this correct ?<br>values['Submit']='True'<br>data = urllib.urlencode(values)<br>req = urllib2.Request(url,data)<br>
response = urllib2.urlopen(req,data)<br>the_page = response.read()<br>print the_page<br><br clear="all">PHP/HTML CODE:<br>html><br><br><body><br>    <?php<br>    if(isset($_POST["Submit"]))<br>    {<br>
       echo "upload-file-name:".$_FILES['datafile']['name']."<br/>";<br><br>    } else {<br>              ?><br>        <form enctype="multipart/form-data" action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post"><br>
        Please enter a file name :<input type="file" name="datafile"  size="100"><br>         <input type="submit" value="submit" name="Submit"/><br>
        </form><br>        <?php<br>    }<br>    ?><br></body><br></html><br><br>But the <b>$_FILES['datafile']['name']</b> in response is always empty...I can not guess what went wrong with my code ,<br>
I will be happy, if you can figure out the problem. <br><br><br>-- <br>Yours,<br>S.Selvam<br>