lexlex
Новичок
upload files через fsockopen превышение memory limit
Пользуюсь вот этим скриптом для закчки файлов.
При файлах мегабайта 4 выдает ошибку.
Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 35 bytes)
Это можно как-нибудь обойти? Например, считывать не весь сразу файл в переменную $content_file.
Пользуюсь вот этим скриптом для закчки файлов.
PHP:
<?php
// get the necessary data
$file_name = $_FILES['userfile']['name']; // the file
$tmp_name = $_FILES['userfile']['tmp_name']; // the file
$content_type = $_FILES['userfile']['type']; // the file mime type
srand((double)microtime()*1000000);
$boundary = "---------------------".substr(md5(rand(0,32000)),0,10);
// Build the header
$header = "POST $remote_url HTTP/1.0\r\n";
$header .= "Host: $remote_server\r\n";
$header .= "Content-type: multipart/form-data, boundary=$boundary\r\n";
// attach post vars
foreach($_POST AS $index => $value){
$data .="--$boundary\r\n";
$data .= "Content-Disposition: form-data; name=\"".$index."\"\r\n";
$data .= "\r\n".$value."\r\n";
$data .="--$boundary\r\n";
}
// and attach the file
$data .= "--$boundary\r\n";
$content_file = join("", file($tmp_name)); //вот здесь ошибка
$data .="Content-Disposition: form-data; name=\"userfile\"; filename=\"$file_name\"\r\n";
$data .= "Content-Type: $content_type\r\n\r\n";
$data .= "".$content_file."\r\n";
$data .="--$boundary--\r\n";
$header .= "Content-length: " . strlen($data) . "\r\n\r\n";
// Open the connection
$fp = fsockopen($remote_server, 80);
// then just
fputs($fp, $header.$data);
fclose($fp);
?>
Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 35 bytes)
Это можно как-нибудь обойти? Например, считывать не весь сразу файл в переменную $content_file.