Error occuring when trying to upload file via FTP using Qt

霸气de小男生 提交于 2019-12-12 03:09:37

问题


I have a file in my folder and I want to send it to my Embedded Linux device via FTP (much like this and this and this). I know the step-by-step to do it, but I'm failing when it comes to creating the correct QUrl for it: when I call ''put'', I always get the error 301:

QNetworkReply::ProtocolUnknownError 301 the Network Access API cannot honor the request because the protocol is not known

As details, I want to save the file in a specific directory located inside a SD Card in the device, /media/mmcblk0p2/bin, and the connection doesn't have, at least for now, a password and user name defined¹. Also interesting to notice that I'm not being able to connect myself via FTP using Terminal; it always says "421 Service not available, remote server has closed connection", which is not the same problem AFAIK. (Btw I'm being able to connect via SSH using FileZilla, so it's not a hardware/physical problem)

So where is the problem? I have exactly the same code as in the mentioned links. As for now, the link I'm using is

ftp://10.1.25.10/media/mmcblk0p2/bin/center.png

(when returning the QUrl object with QDebug) and I'm not being able to make it work.

Any help would be appreciated.

¹: Btw I remember reading somewhere that when one doesn't use a user name for connecting to FTP, the system only allows the client to connect to the /ftp folder. Is that true? In that case, just calling QUrl::setUserName("root"); would suffice?


回答1:


I finally discovered my problem: since I was copying the code from examples of upload to HTTP servers, I was using the function "post", specific for HTTP, instead of "put" which was the correct function to use.

Regarding the QUrl, I used QUrl urlTemp("//10.1.25.10/test.info"); while telling it to use ftp with scheme, urlTemp.setScheme("ftp");.



来源:https://stackoverflow.com/questions/29497160/error-occuring-when-trying-to-upload-file-via-ftp-using-qt

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!