現在、アップロード、サイズ変更、トリミングのスクリプトに取り組んでいます。URL から画像をコピーしてサーバーに保存するのに問題があります。
これは、エラーが発生する私のコードです。ドメインを [MYDOMAIN] に置き換えました。
if(in_array($extension, $extensions_allowed) )
{
$name = explode(".".$extension, $_FILES['image']['name']);
$name = $name[0]."_".time();
move_uploaded_file($_FILES['image']['tmp_name'], "temp/".$name.".".$extension);
// File uploaded to temporary folder, now lets replace the newly created temp image with a resized image
$source = 'timthumb.php?src=http://[MYDOMAIN]/includes/crop/temp/'.$name.'.'.$extension.'&w=398'; // Set source to be the resized image
$dest = $_SERVER['DOCUMENT_ROOT'].'/includes/crop/temp/r'.$name.'.'.$extension; // Destination = temp folder, rdy to be cropped.
if(copy($source, $dest)) {
// If the image was transfered/copied successfully
unlink("temp/".$name.".".$extension); // Remove old temp img. "not the resized"
// The old one has been removed, so now the new file can take its place, lets rename it.
$current = 'temp/r'.$name.'.'.$extension;
$new = 'temp/'.$name.'.'.$extension;
rename($current, $new); // Old temp name becomes the new.
}
else {
echo "Couldnt copy file, try again.";
die();
}
$_SESSION['image']['extension'] = $extension;
$_SESSION['image']['name'] = $name;
//REDIRECT ON SUCCESS
header("Location: /includes/crop/edit.php");
}
私はそれが機能していることを知っているので、完全なコードを書く必要はないと思います。
だから私のmove_uploaded_files()
作品はうまくいきますが、すぐ下のif文でエラーが発生します。
if(copy($source, $dest)) {
// If the image was transfered/copied successfully
unlink("temp/".$name.".".$extension); // Remove old temp img. "not the resized"
// The old one has been removed, so now the new file can take its place, lets rename it.
$current = 'temp/r'.$name.'.'.$extension;
$new = 'temp/'.$name.'.'.$extension;
rename($current, $new); // Old temp name becomes the new.
}
else {
echo "Couldnt copy file, try again.";
die();
}
私のエラーメッセージ:
警告: copy(timthumb.php?src= http://[MYDOMAIN]/includes/crop/temp/SummerVibe Cover_1389227432.jpg&w=398): ストリームを開けませんでした: No such file or directory in /home/[MYHOST]/ 108 行目の public_html/pt/includes/crop/index.php
ファイルをコピーできませんでした。もう一度お試しください。
行 108 がどこにあるのか疑問に思っている場合は、それが のif(copy(ect))
開始行です。
誰かが助けてくれることを願っています。:)
よろしくお願いします、SmK1337