<div dir="ltr"><span style="color:rgb(0,0,0);font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;font-size:14px;line-height:17.804800033569336px">I want to modify the pyqt network ftp demo to include an upload function, but I am failing. Could someone can show me how to do this? I have tried to add this code, but it does not work. [Orignal Demo]</span><a href="https://github.com/Werkov/PyQt4/blob/master/examples/network/ftp/ftp.py" rel="nofollow" style="margin:0px;padding:0px;border:0px;font-size:14px;vertical-align:baseline;color:rgb(74,107,130);text-decoration:none;font-family:Arial,'Liberation Sans','DejaVu Sans',sans-serif;line-height:17.804800033569336px;background-image:initial;background-repeat:initial">https://github.com/Werkov/PyQt4/blob/master/examples/network/ftp/ftp.py</a><br>
<div><br></div><div><pre class="" style="margin-top:0px;margin-bottom:10px;padding:5px;border:0px;font-size:14px;vertical-align:baseline;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif;overflow:auto;width:auto;max-height:600px;word-wrap:normal;color:rgb(0,0,0);line-height:17.804800033569336px;background:rgb(238,238,238)">
<code style="margin:0px;padding:0px;border:0px;vertical-align:baseline;font-family:Consolas,Menlo,Monaco,'Lucida Console','Liberation Mono','DejaVu Sans Mono','Bitstream Vera Sans Mono','Courier New',monospace,serif;white-space:inherit;background-image:initial;background-repeat:initial"><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">buttonBox</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">.</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">addButton</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">(</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">self</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">.</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">uploadButton</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">,</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">
</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(43,145,175);background:transparent">QtGui</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">.</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(43,145,175);background:transparent">QDialogButtonBox</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">.</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(43,145,175);background:transparent">ActionRole</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">)</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">
self</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">.</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">uploadButton </span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">=</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent"> </span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(43,145,175);background:transparent">QtGui</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">.</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(43,145,175);background:transparent">QPushButton</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">(</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(128,0,0);background:transparent">"upload"</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">)</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">
self</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">.</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">uploadButton</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">.</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">clicked</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">.</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">connect</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">(</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">self</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">.</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">selectFile</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">)</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">
</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(0,0,139);background:transparent">def</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent"> selectFile</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">(</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">self</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">):</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">
self</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">.</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">filename </span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">=</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(43,145,175);background:transparent">QtGui</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">.</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(43,145,175);background:transparent">QFileDialog</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">.</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">getOpenFileName</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">()</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">
up_fname </span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">=</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent"> re</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">.</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">sub</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">(</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">r</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(128,0,0);background:transparent">".*/"</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">,</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(128,0,0);background:transparent">""</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">,</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">self</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">.</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">filename</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">)</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">
upload_file </span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">=</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent"> </span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(43,145,175);background:transparent">QtCore</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">.</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;color:rgb(43,145,175);background:transparent">QFile</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">(</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">self</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">.</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">filename</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">)</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">
self</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">.</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">ftp</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">.</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">put</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">(</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">upload_file</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">,</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent"> up_fname</span><span class="" style="margin:0px;padding:0px;border:0px;vertical-align:baseline;background:transparent">)</span></code></pre>
</div></div>