PHP-看不到我的图像
我是php程序员的初学者,所以我遇到了各种各样的问题,其中一个是在我制作了一个简单的上传系统之后,当我想看到上传到服务器上的图片时,没有显示出来。 代码如下:PHP-看不到我的图像,php,Php,我是php程序员的初学者,所以我遇到了各种各样的问题,其中一个是在我制作了一个简单的上传系统之后,当我想看到上传到服务器上的图片时,没有显示出来。 代码如下: <?php $target_path = "uploads/"; $target_path = $target_path . basename( $_FILES['file']['name']); //the target path that the file will move /*Moving the picture,to th
<?php
$target_path = "uploads/";
$target_path = $target_path . basename( $_FILES['file']['name']); //the target path that the file will move
/*Moving the picture,to the server if successed the condition will be true*/
if(move_uploaded_file($_FILES['file']['tmp_name'], $target_path))
{
echo"התמונה הועלתה בהצלחה!";
echo"</br></br>";
echo $target_path;
$show_photo = "<img src='$target_path' alt='Picture' class='photo' />";
function AddToAllPhotosList()
{
$myFile = "photosorder.php"; //ListOfAllPhotos
$fileHander = fopen($myFile,'a') or die ("אין אפשרות לפתוח את הקובץ");
}
}
else
echo "Error.";
?>
行“”,没有显示照片为什么?$show_photo=“”;
$show_photo = "<img src='$target_path' alt='Picture' class='photo' />";
替换为:
echo "<img src='$target_path' alt='Picture' class='photo' />";
echo”“;
HTML被保存到变量$show\u photo中,但没有被回显
。。。
$show_photo=“”;
echo$show\u照片强>
…看起来您实际上并没有输出标记。您当前正在将它们存储在$show_photo变量中,这会给您带来问题。或者
echo $show_photo;
声明后,或将第10行替换为以下内容:
echo "<img src='$target_path' alt='Picture' class='photo' />";
echo”“;
注意-使用的引号类型很重要 添加$show\u photo的回显,该回显应显示要显示的html。尝试执行回显$show\u photo,查看它是否引用了正确的$target\u路径。
$target\u path
的值是多少?它可能是一个类似于C:/www/site/images/img.ext的磁盘路径,需要转换为:http://www.mysite.com/images/img.ext
dsebert我忘了添加echo-_-真的非常感谢:)!!!!!!!!!!!!!!