C# - Can't Upload File Http With Libcurl

Mar 20, 2011

I am using libcurnet for posting some fields and html or pdf file to server. I post fields but can not upload file to server.

Here is my code :
public static void Main(String[] args)
{ try {
Curl.GlobalInit((int)CURLinitFlag.CURL_GLOBAL_ALL);
FileStream fs = new
FileStream(args[0], FileMode.Open, FileAccess.Read, FileShare.Read);
Easy easy = new Easy();
Easy.ReadFunction rf = new Easy.ReadFunction(OnReadData);
easy.SetOpt(CURLoption.CURLOPT_READFUNCTION,rf);
easy.SetOpt(CURLoption.CURLOPT_UPLOAD, true);
easy.SetOpt(CURLoption.CURLOPT_PUT, true);
easy.SetOpt(CURLoption.CURLOPT_URL, args[1]);
easy.SetOpt(CURLoption.CURLOPT_READDATA, fs);
easy.SetOpt(CURLoption.CURLOPT_INFILESIZE, fs.Length);
Easy.DebugFunction df = new Easy.DebugFunction(OnDebug);
easy.SetOpt(CURLoption.CURLOPT_DEBUGFUNCTION, df);
easy.SetOpt(CURLoption.CURLOPT_VERBOSE, true);
Easy.ProgressFunction pf = new Easy.ProgressFunction(OnProgress);
easy.SetOpt(CURLoption.CURLOPT_PROGRESSFUNCTION, pf);
Easy.WriteFunction wf = new Easy.WriteFunction(OnWriteData);
easy.SetOpt(CURLoption.CURLOPT_WRITEFUNCTION, wf);
easy.SetOpt(CURLoption.CURLOPT_POSTFIELDS, args[2]);
easy.SetOpt(CURLoption.CURLOPT_USERAGENT, "Mozilla 4.0 (compatible; MSIE 6.0; Win32");
easy.SetOpt(CURLoption.CURLOPT_FOLLOWLOCATION, true);
easy.SetOpt(CURLoption.CURLOPT_POST, true);
easy.SetOpt(CURLoption.CURLOPT_VERBOSE, 1);
easy.SetOpt(CURLoption.CURLOPT_STDERR, 0);
easy.Perform();
easy.Cleanup();
fs.Close();
Curl.GlobalCleanup(); } catch (Exception ex) {
Console.WriteLine(ex); } }

View 1 Replies


Similar Messages:

HTTP File Upload Works Internally In IIS?

Feb 4, 2011

I'd like to understand what happen under the hood when you do an web upload. I guess one of these: The file is loaded in memory by the browser, sent to the web server buffer memory, and then the app is notified to collect it. The file is being readed by the browser and at the same time sent to the web server, that can start to save the bytes progresively. I've tried to upload a very large file, and put a breakpoint on the frist line of the method receiving the upload. I've seen how the browser toke a lot of time loading... but the breakpoint was still not hit, and after a while the breakpoint is hit. I want to understand this, because in the worst scenario, if I allow big uploads, they could blow up the server memory at some point. What does happen if I upload a 2Gb file? (considering that the web server/app accepts that length) would it take 2Gb of server memory?

View 1 Replies

Upload File To ASP Web Service With HTTP / 1.1 POST

Mar 23, 2011

I'm trying to upload a file to an ASP 2.0 web service through HTTP 1.1 POST from a client-side application. If my web service function is declared as

<WebMethod()>
Public Function UploadFile(ByVal file as Byte(), ByVal fileName as String) as String
...

The test form says the request should take this form:

POST address_of_service HTTP/1.1
Host: <host>
Content-Type: application/x-www-form-urlencoded
Content-Length: length
file=string&file=string&fileName=string

How do I get my binary file data into that form? I've tried just converting the file data to a string and putting it in the body (file=<string_data_here>) but I get HTTP 500 errors back, complaining about not being able to convert it to System.Byte. I've got HTTP POST working fine elsewhere in my application with plain string parameters. Also, out of curiosity, why is it showing the file parameter twice?

View 1 Replies

Use HTTP PUT Method To Upload Local File To Server?

Dec 30, 2010

In my current project, my client application first talk with the server and the server returned an upload url for me to upload a file, the url looks like this: [URL] Then I want to use HTTP PUT method to upload the local "c:pesult.cab" to the above loacation. How could I do this? And could anyone give me a detailed description about the whole uploading mechanism? When I use a ASP.NET upload control, I just click the browse button to locate my file and click submit, and on the server side, I just call the SaveAs() method of the upload control. Here is some code:

protected void UploadButton_Click(object sender, EventArgs e)
{
if(FileUploadControl.HasFile)
{
try
{
string filename = Path.GetFileName(FileUploadControl.FileName);
FileUploadControl.SaveAs(Server.MapPath("~/") + filename);
StatusLabel.Text = "Upload status: File uploaded!";
}
catch (Exception ex)
{
StatusLabel.Text = "Upload status: The file could not be uploaded. The following error occured: " + ex.Message;
}
}
}

Who is responsible for reading the file and sending it? What happens when I call FileUploadControl.SaveAs() method? Does the server pull the file from client, or the client push the file to the server? I know HTTP is text based, but my result.cab is not text, so is it Base64 encoded before being sent? How does HTTP PUT method work? Is it a client side push, or a server side pull? Or interaction of both like some kind of handshake?

View 1 Replies

File Upload To HTTP Server From IPhone Application

Jan 11, 2010

Could someone please tell me/link me to how I could create a method similar to those posted below: [URL] (I am providing the links as I'm not sure how to articulate this question without them!) I'm using C# ASP.NET. IIS 6. I have an existing web server with other public API methods. I do not want the iPhone user to have to open a web browser, and post to an aspx page. I want the iPhone developer to be able to call my method, and have one of the parameters be a handle to the file which gets POSTed.

View 1 Replies

How To Get Login To Another Site And Upload File Using Http Webrequest

Jun 16, 2010

logging to another website and uploading file to that site.

View 1 Replies

AJAX :: Async File Upload Control - Check File Contenttype Before File Upload Starts?

Jan 13, 2010

I am using the async file upload control to upload to a image file. I want the user to upload only jpg files. And for that I am checking the uploadedfile content type in server side, after the upload complets. I wanna check this, before upload starts. There is one javascript method

function startUpload(sender, args){}

but how to access the content type of the file selected by user.

View 5 Replies

C# - Unable To Load DLL 'libcurl.dll' - The Specified Module Could Not Be Found

Mar 18, 2011

I am using LibCurlNet on my asp.net project. I post some fields to server with it. I downloaded library and added it to my project as reference. At first I could run my project.

But now when I run project, I have an exception:

[code]...

and I have the exception at line "Curl.GlobalInit((int)CURLinitFlag.CURL_GLOBAL_ALL);"

When I try to add reference to my project, in bin folder I found three .dll file but I just add the "LibCurlNet.dll".

View 1 Replies

Web Forms :: How To Upload File And Save It To Oracle Database And View The Upload File Using C#

Feb 8, 2011

how to upload and save files to oracle database, and view file using C# .net and can upload one or more files in one webform.

View 1 Replies

Web Forms :: Can Upload A File On A Network Share Folder Using File Upload Control

Aug 6, 2010

I want to upload files to the web servers from the client machines.

Can i upload a file on a network share folder using file upload control?

I would like to create a share folder on a file server sitting next to the web server. If i upload the file from the network share folder instead of uploading it from the client machine does it make any difference?

Will the file be stored in a temporary location before copying to the final destination? Where will be the file stored in this case of uploading it from share folder?

View 1 Replies

Web Forms :: Unable To Upload File More Than 4MB Using The File Upload Tool?

Dec 10, 2010

I am using the File Uploader to upload files. It is working fine. But I receive the page can not be displayed when I try to upload a file>4Mb in size.

View 1 Replies

Web Forms :: Upload 2gb File Using File Upload Control?

Apr 1, 2012

i have problem in uploading 2gb video file using file upload control in asp.net, i have limit the maximum file size in web config file then also it shows error any remedy for that...

View 1 Replies

Web Forms :: Upload A File Without Using File Upload Control

May 14, 2012

I want to upload a file without using the file upload control in asp.net.

View 1 Replies

File Upload Control And Not Permitting User To Upload Over 500px In WIDTH ?

Sep 24, 2010

I have a file upload control on my page with a regular expression validator that handles the file format.

Users can upload files but I want the maximum WIDTH size to be 500px.

If any bigger I need to show a message advising the width is to great and stops them.

View 3 Replies

Web Forms :: File Uploader To Upload Files To A Folder Used For Upload

Jul 15, 2010

Im using a file uploader to upoad files to a folder used for upload.But the problem is this folder is a linux folder. I have made it a shared folder so that I can access from windows by samba. So, file transfer is successful when I'm using os but when I try to upload something from my websites uploader to this folder, this process is not successful. I have given all permissions to this folder.Don't know whats the problem.I have used both type of slashes for directory but still it is not successful.

View 4 Replies

Is It Possible To Restrict Users To Not Be Able To Upload .msg Or .gifs With The .net File Upload

Aug 11, 2010

I need to figure out a way to prevent users from uploading a couple file types in my vb.net page. How can I prevent users from uploading .msg or .gifs during a file upload?

View 3 Replies

Web Forms :: How To Stop An Upload Pop-up Box From Closing After A File Upload

Nov 16, 2010

I have a file upload area and would like to stop the pop-up box area from closing when the user has uploaded their file. Anyone know how I can do this ? this is the code:

[code]...

View 1 Replies

How To Use The File Upload Control To Upload Word Documents

Apr 5, 2011

Anyone know how to use the file upload control to upload word docs etc

View 3 Replies

C# - Unable To Upload Files Through File Upload Control?

May 31, 2010

i am trying to upload files through the ASP.NET File Upload control.

Every thing is working fine, except for the fact that when i try to upload the file on the server i am getting an error: (probably some authorization exception).

do i need to give some rights to the upload up there on the server. If so then for which account and do i need to restart the server after giving rights?

View 2 Replies

AJAX :: Attach A File Using File Upload Control And Send It In Email Along With Already Attached File

Apr 27, 2016

I have an asp.net panel having various controls including gridview. I have converted this panel into pdf and attached it as an email attachment using memory stream. Everything is working fine. Now I have an File upload control outside panel through which I have to attach a file and send it in mail along with the already attached panel. But I am unable to figure out how to do it.

View 1 Replies

How To Use File Upload Control To Upload The Files

Aug 23, 2010

i am using file upload control to upload the files in asp.net with vb.net as code behind. am storing the files in my local drive. my doubt is, how shall i read those file using asp.net application.

View 1 Replies

Vb.net - Upload Mutiple Images With One File Upload?

Dec 28, 2010

How to upload mutiple images with one file up;oad like in facebook or orkut using asp.net(VB).

View 1 Replies

PDF Won't Upload Using File Upload Control?

Jan 10, 2013

I'm trying to upload a PDF file using our web app. I'm using the FileUpload control. The file I tried to upload was 4.7mb in size. I was unable to upload this file. I tried uploading another PDF file that was 936KB in size and it was fine. What would prevent this. Does the FileUpload control have a size restriction on it?

View 2 Replies

How To Get Posted File From Upload File Or Html In Put File

Feb 2, 2011

my project is in c sharp and must upload pictures to MySql DataBasethe uploadfile controle is included in asp form that i made but the problem is that the uploadfile always get the Postedfile = null i tried to use html input file but the same problem still
@&nbsp;Page&nbsp;Language="C#"&nbsp;MasterPageFile="~/MasterPageB.master"&nbsp;AutoEventWireup="true"&nbsp;CodeFile="test.aspx.cs"&nbsp;Inherits="Add_Pictures"&nbsp;Title="Untitled&nbsp;Page"&nbsp;%>
<%@&nbsp;MasterType&nbsp;TypeName="MasterPageB"&nbsp;%>
<%@&nbsp;Register&nbsp;assembly="MyFormView"&nbsp;namespace="MyFormView"&nbsp;tagprefix="asp"&nbsp;%>
[code]...

View 1 Replies

Web Forms :: Upload File Directly Without "upload" Button?

Jun 14, 2010

Is it possible to directly upload a file after it is browsed and selected? I mean user should not click on "submit" button after file is selected. It should be uploaded automatically when selected. Is it possible to do that with fileupload control?

View 5 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved