English 中文(简体)
如何掌握服务器上储存的图像
原标题:How to get an URL of an image which has been stored on server

它必须是非常容易的,但我没有从服务器中获取URL图像的方法。

让我们说,我已用域名www.example.com,图像已储存在我。

htdocs>www>resources>userid>images>image.jpg

So, I want upload an image and save it through php script into my images folder and return the URL of that image back to browser like,

www.example.com/.../.../images/image.jpg

Is there any php function to get URL of a file?

EDIT:

我认为,在审视答案之后,我应进一步澄清我自己的意思。 我确实对误解感到担忧,

www.un.org/spanish/ecosoc 我想得到的帮助是:。 如果域名固定不变,我就意味着你可以下载并附上我的形象上上载者,但现在它应该有活力地获得域名和网页,以达到你们的形象。

最佳回答

既然我没有钱,那就不知道你的法典。 我下面的猜测,希望你能够根据你的法典加以修改。

Suppose i download your plugin to my website and upload an image using it. You can get the image path like this:

<?php
$upload_path =  PATH_WHERE_IMAGE_IS_UPLOADED ;
$image_name =  NAME_OF_THE_UPLOADED_IMAGE ;

$relative_path = $upload_path . DS . $image_name;

$path = str_replace( $_SERVER[ DOCUMENT_ROOT ], $_SERVER[ SERVER_NAME ]
                                                            , $relative_path );

$path =  http://  . $path; // this is where image is uploaded
?>

<>说明: 假设上载目录属于烟雾。

Hopefully, this will work.

问题回答

引言

$image= name of your image uploaded ;
$imageurl= http://www.example.com/images .$image;
echo  <input type=text name="image" value=" .$imageurl. " disabled />;

<><>Editted>

举例说:

$domain = $_SERVER[ SERVER_NAME ];
$uploadPath = "/htdocs/www/resources/userid/images/image.jpg"

// replace "/htdocs/www", with an empty string
$subdir = str_replace("/htdocs/www", "", $uploadPath);

$url = $domain.$subdir;

可查阅PHP功能的人工网页move_uploaded_file()。 如果我理解你的问题,解决办法就是这样。





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签