解決済み問題!!!PHPで画像を作成し、サーバフォルダに保存する
モニは私が
imagejpeg
に3つのパラメータを渡す必要がありますが、小さな修正は、それがimagejpeg($im,$save,100)
画質が品質の写真を得るためになければならないことになってimagejpeg($im,$save,0)
すべきではないと述べたよう画像フォルダが適切な出力を得るために、スラッシュ「画像/ FB /」
imagecolorallocate
imagecolorallocate($im, 142, 011, 029)
3桁のまたRGBなしです。
ので、このための答えと完全なコードは以下の通りである
<?php
// Create image with 2 line of text
$im = imagecreatetruecolor(600, 300);
$text_color = imagecolorallocate($im, 142, 011, 029);
imagestring($im, 10, 5, 5, 'Some Text String', $text_color);
imagestring($im, 10, 5, 50, 'Some Text String 2', $text_color);
// Set the content type header as image/jpeg
header('Content-Type: image/jpeg');
// Output the image
//imagejpeg($im); //up-to this point its working well
$name="test2";
$save = "images/fb/". strtolower($name) .".jpeg";
imagejpeg($im, $save, 100); //Saves the image
imagejpeg($im); //Displays the image
// Free up memory
imagedestroy($im);
?>
問題
私はこの問題を解決するために私を助けてください、
I PHPで画像を作成しようとしていて、作成した画像をフォルダ内に保存しようとしましたが、画像が表示されましたが、フォルダに保存を追加すると、私には誤りです。以下は私が試したコードです。
<?php
// Create image with 2 line of text
$im = imagecreatetruecolor(600, 300);
$text_color = imagecolorallocate($im, 142, 11, 29);
imagestring($im, 10, 5, 5, 'Some Text String', $text_color);
imagestring($im, 10, 5, 50, 'Some Text String 2', $text_color);
// Set the content type header as image/jpeg
header('Content-Type: image/jpeg');
// Output the image
//imagejpeg($im); //up-to this point its working well
$name="test";
$save = "/images/fb/". strtolower($name) .".jpeg";
imagejpeg($im, $save, 0, NULL);
// Free up memory
imagedestroy($im);
?>
次私は私のフォルダ構造は、私もchmod
で試してみましたが、その私はだから許可が問題ではないようです
->www
-> projectFolder
-> subFolder
->phpFile
->imageFolder (images)
->imageSubFolder (fb)
ある
The image "path" cannot be displayed because it contains errors.
を取得していますエラーですLocalhostでこれを試してみてください。
何かアドバイスをいただければ幸いです...
はあなたですパス '/ images/fb /'が存在することを確認してください。 '/'はローカルの 'images/fb /'フォルダではなくサーバー上のメインフォルダであることを意味します – nospor
おそらくあなたのパスは間違っていますか?エラーは何ですか? –
_ "...それは私にエラーを与えている" _ ...そしてエラーは何ですか? –