How to upload file using Selenium WebDriver in Java

First make sure that the input element is visible As stated by Mark Collin in the discussion here: Don’t click on the browse button, it will trigger an OS level dialogue box and effectively stop your test dead. Instead you can use: driver.findElement(By.id(“myUploadElement”)).sendKeys(“<absolutePathToMyFile>”); myUploadElement is the id of that element (button in this case) and … Read more

how to upload file using curl with PHP [closed]

Use: if (function_exists(‘curl_file_create’)) { // php 5.5+ $cFile = curl_file_create($file_name_with_full_path); } else { // $cFile=”@” . realpath($file_name_with_full_path); } $post = array(‘extra_info’ => ‘123456’,’file_contents’=> $cFile); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$target_url); curl_setopt($ch, CURLOPT_POST,1); curl_setopt($ch, CURLOPT_POSTFIELDS, $post); $result=curl_exec ($ch); curl_close ($ch); You can also refer: http://blog.derakkilgo.com/2009/06/07/send-a-file-via-post-with-curl-and-php/ Important hint for PHP 5.5+: Now we should use https://wiki.php.net/rfc/curl-file-upload but if … Read more

C# HttpClient 4.5 multipart/form-data upload

my result looks like this: public static async Task<string> Upload(byte[] image) { using (var client = new HttpClient()) { using (var content = new MultipartFormDataContent(“Upload—-” + DateTime.Now.ToString(CultureInfo.InvariantCulture))) { content.Add(new StreamContent(new MemoryStream(image)), “bilddatei”, “upload.jpg”); using ( var message = await client.PostAsync(“http://www.directupload.net/index.php?mode=upload”, content)) { var input = await message.Content.ReadAsStringAsync(); return !string.IsNullOrWhiteSpace(input) ? Regex.Match(input, @”http://\w*\.directupload\.net/images/\d*/\w*\.[a-z]{3}”).Value : null; } … Read more

How to upload a file in Django? [closed]

Phew, Django documentation really does not have good example about this. I spent over 2 hours to dig up all the pieces to understand how this works. With that knowledge I implemented a project that makes possible to upload files and show them as list. To download source for the project, visit https://github.com/axelpale/minimal-django-file-upload-example or clone … Read more

Upload files with HTTPWebrequest (multipart/form-data)

Took the code above and fixed because it throws Internal Server Error 500. There are some problems with \r\n badly positioned and spaces etc. Applied the refactoring with memory stream, writing directly to the request stream. Here is the result: public static void HttpUploadFile(string url, string file, string paramName, string contentType, NameValueCollection nvc) { log.Debug(string.Format(“Uploading … Read more