Function UploadFile

Synopsis

#include <lib/inc/drogon/UploadFile.h>

explicit UploadFile(const std::string &filePath, const std::string &fileName="", const std::string &itemName="file")

Description

Constructor.

Parameters

filePath - The file location on local host, including file name.

fileName - The file name provided to the server. If it is empty by default, the file name in the

filePath - is provided to the server.

itemName - The item name on the browser form.

Source

Lines 35-56 in lib/inc/drogon/UploadFile.h.

explicit UploadFile(const std::string &filePath,
                    const std::string &fileName = "",
                    const std::string &itemName = "file")
    : path_(filePath), itemName_(itemName)
{
    if (!fileName.empty())
    {
        fileName_ = fileName;
    }
    else
    {
        auto pos = filePath.rfind('/');
        if (pos != std::string::npos)
        {
            fileName_ = filePath.substr(pos + 1);
        }
        else
        {
            fileName_ = filePath;
        }
    }
}





Add Discussion as Guest

Log in