08-31-2015 09:21 AM
i try to upload file to server by HTTP POST
the server ask for login ( username , PW)
to run XML commands on this server i am using activeX - MSXML2.IXMLHTTPRequest and all Ok .
can i use this Activx for upload file ?if yes how ?
can i use http Vis ? ( need exmple with login)
below i have exmple in .net how to that
i tryed to connectivity to .net but not found the class WebClien .....
thanks
WebClient wc = new WebClient();
wc.Credentials = new NetworkCredential("Company", "Password");
wc.Headers.Add("Accept", "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/x-ms-application, application/x-ms-xbap, application/vnd.ms-xpsdocument, application/xaml+xml, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*");
wc.Headers.Add("Referer", "http://" + this.host + "/upgrade.html");
wc.Headers.Add("Accept-Encoding", "gzip, deflate");
wc.Headers.Add("User-Agent", "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C; .NET4.0E; InfoPath.3)");
wc.Headers.Add("Authorization", "Basic SGFybW9uaWM6aGxpdGluMQ==");
//wc.UploadProgressChanged += new UploadProgressChangedEventHandler(wc_UploadProgressChanged);
wc.UploadFileCompleted += new UploadFileCompletedEventHandler(UploadFileCallback);
wc.UploadFileAsync(new Uri("http://" + this.host + "/InstallFirmware"), "POST", uploadfile);
09-01-2015 04:30 AM
Look at the HTTP Post Multipart VI in the HTTP Client VIs - you should be able to POST your file using that by specifying the file path and field name in the bundle by name and then build array. To set the username/password (I'm assuming it's simple HTTP AUTH) you can specify those on the Open Handle VI.
The .NET web client should also work too (on Windows) - finding stuff in the .NET browser can be a pain but I'm sure it'll be there. Looking at the .NET help documentation on MSDN should help you to find it.
09-01-2015 08:43 AM
09-01-2015 08:46 AM
How about you post the VI you have created (screenshot, attach the VI (<= LV 2014) or create a VI snippet) to show what you have tried and I will look at it?
09-01-2015 08:58 AM
i try to do that by .net .
labview 2012 .
attached the sendfile.vi
09-01-2015 09:15 AM - edited 09-01-2015 09:19 AM
What is the error you are getting?
If you're not registering for the callback event (you would need to create a callback VI etc.), I would try doing a synchronous file upload first so you can see if/when the upload completes.
I would think that if you don't leave the VI running with the asynchronous upload, it probably clears up all the .NET references when the VI stops running - terminating the webclient reference before the upload has completed. You can check this with the Desktop Execution Trace Toolkit.
08-17-2016 04:15 AM
Regards.
Digant Shetty (LV 18.0)
AE, Combined Digilog Systems Pvt. Ltd.