I'm having an issue on my development machine which seems isolated to this machine and I can't figure it out. I have a jQuery file uploader which posts the user-selected file to a PHP script for handling using XmlHttpRequest. The script works fine on my MacBook Pro running OSX10.6.3 with MAMP 1.9, however on my iMac with the exact same operating system and version of MAMP, with an identical server image, it fails.
I $_SERVER["CONTENT_LENGTH"]
Ben sadece iyi dosya alabilirsiniz ve her şey isteği hakkında başarmış görünüyor olsa bile, 0 dönen özelliği aşağı hata nedenini takip var. Nedense sadece bana gerçek içerik uzunluğu vermek gibi olmayacaktır. Burada soruna neden olan kodu - söz konusu işlevi
getSize()
.
class qqUploadedFileXhr {
/**
* Save the file to the specified path
* @return boolean TRUE on success
*/
function save($path) {
$input = fopen("php://input", "r");
$temp = tmpfile();
$realSize = stream_copy_to_stream($input, $temp);
fclose($input);
if ($realSize != $this->getSize()){
return false;
}
$target = fopen($path, "w");
fseek($temp, 0, SEEK_SET);
stream_copy_to_stream($temp, $target);
fclose($target);
return true;
}
function getName() {
return $_GET['qqfile'];
}
function getSize() {
if (isset($_SERVER["CONTENT_LENGTH"])){
return (int)$_SERVER["CONTENT_LENGTH"]; //*THIS* is returning 0
} else {
throw new Exception('Getting content length is not supported.');
}
}
}