fileReader.readAsBinaryString to upload files

(Following is a late but complete answer) FileReader methods support FileReader.readAsBinaryString() is deprecated. Don’t use it! It’s no longer in the W3C File API working draft: void abort(); void readAsArrayBuffer(Blob blob); void readAsText(Blob blob, optional DOMString encoding); void readAsDataURL(Blob blob); NB: Note that File is a kind of extended Blob structure. Mozilla still implements readAsBinaryString() … Read more

how to upload file using curl with PHP

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

How to gracefully handle files that exceed PHP’s `post_max_size`?

From the documentation : If the size of post data is greater than post_max_size, the $_POST and $_FILES superglobals are empty. This can be tracked in various ways, e.g. by passing the $_GET variable to the script processing the data, i.e. <form action=”edit.php?processed=1″>, and then checking if $_GET[‘processed’] is set. So unfortunately, it doesn’t look … Read more

Uploading Files in ASP.net without using the FileUpload server control

In your aspx : <form id=”form1″ runat=”server” enctype=”multipart/form-data”> <input type=”file” id=”myFile” name=”myFile” /> <asp:Button runat=”server” ID=”btnUpload” OnClick=”btnUploadClick” Text=”Upload” /> </form> In code behind : protected void btnUploadClick(object sender, EventArgs e) { HttpPostedFile file = Request.Files[“myFile”]; //check file was submitted if (file != null && file.ContentLength > 0) { string fname = Path.GetFileName(file.FileName); file.SaveAs(Server.MapPath(Path.Combine(“~/App_Data/”, fname))); } … Read more

Python Script Uploading files via FTP

Use ftplib, you can write it like this: import ftplib session = ftplib.FTP(‘server.address.com’,’USERNAME’,’PASSWORD’) file = open(‘kitten.jpg’,’rb’) # file to send session.storbinary(‘STOR kitten.jpg’, file) # send the file file.close() # close file and FTP session.quit() Use ftplib.FTP_TLS instead if you FTP host requires TLS. To retrieve it, you can use urllib.retrieve: import urllib urllib.urlretrieve(‘ftp://server/path/to/file’, ‘file’) EDIT: … Read more

CFBundleVersion in the Info.plist Upload Error

There’s at least 1 known bug in Apple’s upload server that they’ve not fixed for more than 12 months. Things to beware of: Apple deletes any leading zeroes inside the version number; i.e. the “whole string” is NOT treated as a number, instead the bits between dots are treated as SEPARATE numbers. e.g. “1.02” is … Read more

Save image from URL by paperclip

In Paperclip 3.1.4 it’s become even simpler. def picture_from_url(url) self.picture = URI.parse(url) end This is slightly better than open(url). Because with open(url) you’re going to get “stringio.txt” as the filename. With the above you’re going to get a proper name of the file based on the URL. i.e. self.picture = URI.parse(“http://something.com/blah/avatar.png”) self.picture_file_name # => “avatar.png” … Read more