-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upload file to FTP server (Ubuntu) #51
Comments
Hello, First of all, you must put your code inside a function (ex: int main() { // put code here }). I ll try to give you an example before the end of the day that you can build on Ubuntu without CMake. If you don't connect a secure FTP server (SFTP, FTPS/FTPES), you don't need to use the methode SetInsecure(true). Also, if the FTP server is not an active one (very rare), you must not set active to true. Regards. |
Thank you very much!! I will put the code inside an upload() function which will have an input argument as a string. The input variable is a JPG image. @embeddedmz |
@victoriastraberg I tested this example with an FTP server hosted at 192.168.1.17:21 on my local network and a user account named "test" with a password "0123456789C++" :
You can copy/paste that code in a main.cpp file that you can place in the same directory as the ftpclient-cpp/FTP/ and run this command in a terminal to compile the program : Explanations : To run the program : |
It works! Thank you! @embeddedmz See attached image below. I get these warnings when I write -DLINUX and when I remove -DLINUX I get "could not find #include <direct.h>..." How come? |
LINUX preprocessor macro must be defined because in the header file there's these preprocessor instructions
<direct.h> is a header that exists only with Microsoft Visual Studio C/C++ API and contains mkdir() function used to create a directory. LINUX macro must be defined so that the C++ GNU compiler's preprocessor doesn't include it in the code that will be compiled. You can ignore the warnings, they are related to obsolete elements in newer versions of libcurl. You can't see them if the LINUX macro processor is not defined because the compiler stops when it comes across the error related to <direct.h>. |
@embeddedmz Ok, thanks! :) Unfortunately I get every file stored in my local folder. How could I just upload the file without saving it locally? |
You can specify the absolute path to the file e.g. "/home/user/test_upload.txt". In the example above, I used a relative path but you can also use absolute paths. Example : On Windows : |
Yes exactly. I already do like this - the problem is that the image still gets saved in the code folder. See here: |
Can you show me the code using the upload() function ? (by the way, you don't need to use c_str() method when concatenating strings and when using UploadFile()). I want to see how the image is stored in memory. UploadFile has this "overloading" :
Depending on the code that retrieves an image from the camera and keeps it somewhere in memory, I could help you write the code that uses this overloading. Something like this :
I can also add an overloading to the API having this signature if you want : |
Hi! @embeddedmz
Im working with c++ code in Ubuntu and want to upload files/images to my FTP server. See attached images. How could I solve this? I have installed libcurl.
Thanks in advance!
The text was updated successfully, but these errors were encountered: