File upload support for webternet (r=psychonic).
This commit is contained in:
parent
22d11160ba
commit
25fced78e8
@ -18,6 +18,18 @@ bool WebForm::AddString(const char *name, const char *data)
|
||||
return lastError == CURL_FORMADD_OK;
|
||||
}
|
||||
|
||||
bool WebForm::AddFile(const char *name, const char *path)
|
||||
{
|
||||
lastError = curl_formadd(&first,
|
||||
&last,
|
||||
CURLFORM_COPYNAME,
|
||||
name,
|
||||
CURLFORM_FILE,
|
||||
path,
|
||||
CURLFORM_END);
|
||||
return lastError == CURL_FORMADD_OK;
|
||||
}
|
||||
|
||||
curl_httppost *WebForm::GetFormData()
|
||||
{
|
||||
return first;
|
||||
|
@ -44,6 +44,7 @@ public:
|
||||
~WebForm();
|
||||
public:
|
||||
bool AddString(const char *name, const char *data);
|
||||
bool AddFile(const char *name, const char *path);
|
||||
public:
|
||||
curl_httppost *GetFormData();
|
||||
private:
|
||||
|
@ -40,7 +40,7 @@
|
||||
*/
|
||||
|
||||
#define SMINTERFACE_WEBTERNET_NAME "IWebternet"
|
||||
#define SMINTERFACE_WEBTERNET_VERSION 2
|
||||
#define SMINTERFACE_WEBTERNET_VERSION 3
|
||||
|
||||
namespace SourceMod
|
||||
{
|
||||
@ -79,6 +79,17 @@ namespace SourceMod
|
||||
* @return True on success, false on failure.
|
||||
*/
|
||||
virtual bool AddString(const char *name, const char *data) = 0;
|
||||
|
||||
/**
|
||||
* @brief Adds a file to the form.
|
||||
*
|
||||
* All data is copied locally and may go out of scope.
|
||||
*
|
||||
* @param name Field name (null terminated).
|
||||
* @param path Local file path (null terminated).
|
||||
* @return True on success, false on failure.
|
||||
*/
|
||||
virtual bool AddFile(const char *name, const char *path) = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user