move_uploaded_file não funciona, nenhum erro
Estou executando um script que move um arquivo carregado commove_uploaded_file()
. Eu fiz isso milhares de vezes, mas por algum motivo não está funcionando. Confimitei o seguinte:
<form>
usandomethod="post"
e corrijaenctype
arquivo correto referenciado a partir do formuláriodirectory tem permissões777
todosmemory_limit
, max_execution_time
, etc estão definidas para configurações super altas para evitar tempos limite Basicamente, o script abaixo retorna com apenasYour image is too big.
. Também habilitei a exibição de TODOS os erros e ainda não recebo um erro. Alguma ideia
$time = time();
$target_path = "/absolute/path/to/temp/directory/temp/";
$target_path = $target_path.$time.'.jpg';
if(move_uploaded_file($_FILES['image']['tmp_name'], $target_path)) {
} else{
$error .= '<li>Your image is too big.</li>';
}
Usando a hospedagem 1and1 com o php.ini hack: P
UPDATE 1
Gostaria de adicionar que a resposta do script ocorra exatamente após 60 segundo
UPDATE 2
Podemos estar chegando a algum lugar com isso. Somenteprint_r($_FILES)
e este é o resultado da matriz:
Array (
[image] => Array (
[name] => P2120267.JPG
[type] =>
[tmp_name] =>
[error] => 1
[size] => 0
)
)
Então, isso me leva a acreditar que o arquivo não foi carregado corretamente no servidor ou algo assim? Eu verifiquei e o formulário de postagem é<form action="" method="post" enctype="multipart/form-data">
. Então, pelo que sei, o arquivo não está sendo carregado na área temporária do servidor?
UPDATE 3
Notou o[error] => 1
na matriz acima. Aparentemente, isso se deve ao tamanho do arquivo é maior que oupload_max_filesize
. No entanto, quando eu defino isso como128M
, Recebo uma tela branca da morte após 60 segundos. O arquivo que estou enviando é de 2,5 MB
Aqui está meu arquivo php.ini:
register_globals=off
memory_limit = 128M
max_execution_time=3600
post_max_size = 128M
upload_max_filesize= 128M
UPDATE 4
Com os detalhes acima, parece que estou recebendo um WSOD, mas a imagem está sendo restaurada. Então, como parar o WSOD? Não consigo encontrar erros relacionados em lugar algum.
UPDATE 5 - ENCONTROU-O!
Shame on me por não dar a vocês todo o código. Parece que tem a ver com esta linha:
resizeImage($feedBurnerStatsSource, PHOTOMSGDIR.'temp/'.$time.'-tmp.jpg',$width,$height);
No código a seguir:
function resizeImage($source, $destination = NULL,$wdt, $height = NULL){
if(empty($height)){
// Height is nit set so we are keeping the same aspect ratio.
list($width, $height) = getimagesize($source);
if($width > $height){
$w = $wdt;
$h = ($height / $width) * $w;
$w = $w;
}else{
$w = $wdt;
$h = $w;
$w = ($width / $height) * $w;
}
}else{
// Both width and Height are set.
// this will reshape to the new sizes.
$w = $wdt;
$h = $height;
}
$source_image = @file_get_contents($source) or die('Could not open'.$source);
$source_image = @imagecreatefromstring($source_image) or die($source.' is not a valid image');
$sw = imagesx($source_image);
$sh = imagesy($source_image);
$ar = $sw/$sh;
$tar = $w/$h;
if($ar >= $tar){
$x1 = round(($sw - ($sw * ($tar/$ar)))/2);
$x2 = round($sw * ($tar/$ar));
$y1 = 0;
$y2 = $sh;
}else{
$x1 = 0;
$y1 = 0;
$x2 = $sw;
$y2 = round($sw/$tar);
}
$slate = @imagecreatetruecolor($w, $h) or die('Invalid thumbnail dimmensions');
imagecopyresampled($slate, $source_image, 0, 0, $x1, $y1, $w, $h, $x2, $y2);
// If $destination is not set this will output the raw image to the browser and not save the file
if(!$destination) header('Content-type: image/jpeg');
@imagejpeg($slate, $destination, 75) or die('Directory permission problem');
ImageDestroy($slate);
ImageDestroy($source_image);
if(!$destination) exit;
return true;
}
WSOD significa que é algum tipo de dado sem mensagem. Alguma ideia