简体   繁体   English

使用php显示上传的图片时出现权限错误

[英]permission error in displaying uploaded image using php

I am using WAMP server and I want to display the image uploaded on the server.. i have successfully implemented the uploading of image..but while displaying it using - 我正在使用WAMP服务器,我想显示在服务器上上传的图像..我已经成功实现了图像的上传..但是使用-

echo ' < img src=\"'.$p.'\" alt=\"Cover\" > ';

where $p contains the path of image, i get a broken image. $ p包含图像的路径,我得到了损坏的图像。 When i right click and select open image in new tab, the following is displayed.. 当我右键单击并在新选项卡中选择打开图像时,将显示以下内容。

Forbidden 禁止的

You don't have permission to access /"c:/wamp/www/folders/shubhi/My on this server. 您无权在此服务器上访问/“ c:/ wamp / www / folders / shubhi / My。

Also this error is not showing complete path which should be "c:/wamp/www/folders/shubhi/My pics/1.jpg" But when i print $p , it displays the correct location. 另外此错误没有显示完整的路径,应该是"c:/wamp/www/folders/shubhi/My pics/1.jpg"但是当我打印$p ,它将显示正确的位置。

What should i do to resolve this? 我应该怎么做才能解决这个问题? Or is there any other method to display the uploaded image having its location stored in a php variable? 还是有其他方法可以显示上传的图像并将其位置存储在php变量中?

You are using absolute path to display image which is wrong. 您正在使用绝对路径显示错误的图像。

To display image on webpage, you need to give http url to that image as below 要在网页上显示图片,您需要为该图片提供http网址,如下所示

$p = 'http://example.com/shubhi/My pics/1.jpg';

echo ' < img src=\"'.$p.'\" alt=\"Cover\" > ';

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM