Skip to main content

Posts

Showing posts with the label header

Cannot properly set the Accept HTTP header with jQuery

I'm trying to set the Accept HTTP header to "text/xml" with this jquery code: $.ajax({ beforeSend: function(req) { req.setRequestHeader("Accept", "text/xml"); }, type: "GET", url: "[proper url]", contentType: "text/plain; charset=utf-8", dataType: ($.browser.msie) ? "text" : "xml", username: '---', password: '-------', success: function(data) { var xml; if (typeof data == "string") { alert("Data is string:" + data); xml = new ActiveXObject("Microsoft.XMLDOM"); xml.async = false; xml.loadXML(data); } else { xml = data; alert("Data is not string:" + $(xml).text()); } // Returned data available in object "xml" //alert("Status is: " + xml.

Limiting download speeds with PHP

I have this code here, however i want to limit the speed the user can download at, how would i implement this into this code; header("Content-type: application/force-download"); header("Content-Transfer-Encoding: Binary"); header("Content-length: ".filesize("uploads/$filename")); header("Content-disposition: attachment; filename=\"$origname"); readfile("uploads/$filename"); Thanks! This is what i tried; $download_rate = 100; $origname = get_file_name($file[0]); header("Content-type: application/force-download"); header("Content-Transfer-Encoding: Binary"); header("Content-length: ".filesize("uploads/$filename")); header("Content-disposition: attachment; filename=\'$origname'"); $local_file = "uploads/$origname"; // flush content flush(); // open file stream $file = fopen($local_file, "r"); while (!feof($