Get mime type of external file using cURL and php

PHP curl_getinfo() <?php # the request $ch = curl_init(‘http://www.google.com’); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_exec($ch); # get the content type echo curl_getinfo($ch, CURLINFO_CONTENT_TYPE); # output text/html; charset=ISO-8859-1 ?> curl curl -I http://www.google.com output HTTP/1.1 301 Moved Permanently Location: http://www.google.com/ Content-Type: text/html; charset=UTF-8 Date: Fri, 09 Apr 2010 20:35:12 GMT Expires: Sun, 09 May 2010 20:35:12 GMT Cache-Control: … Read more

image.onError event never fires, but image isn’t valid data – need a work around

In the image.onload event listener, check whether image.width and image.height are both zero (preferably image.naturalWidth and image.naturalHeight, when they are supported). If the width and height are both zero, the image is considered invalid. Demo: http://jsfiddle.net/RbNeG/ // Usage: loadImage(‘notexist.png’); function loadImage(src) { var image = new Image; image.onload = function() { if (‘naturalHeight’ in this) … Read more

All MIME types supported by MediaRecorder in Firefox and Chrome?

I’ve not seen any sort of comprehensive list yet for Firefox but I have managed to find something (via a post on the MediaRecorder API from Google’s web updates section) that links to this test set that seems to shed some light on things. Essentially, it looks like the following are (at time of writing) … Read more

Determine file type in Ruby

There is a ruby binding to libmagic that does what you need. It is available as a gem named ruby-filemagic: gem install ruby-filemagic Require libmagic-dev. The documentation seems a little thin, but this should get you started: $ irb irb(main):001:0> require ‘filemagic’ => true irb(main):002:0> fm = FileMagic.new => #<FileMagic:0x7fd4afb0> irb(main):003:0> fm.file(‘foo.zip’) => “Zip archive … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)