制作一个基本的网页,网页的唯一目的是能够在本地上传背景图片并显示
制作一个基本的网页,网页的唯一目的是能够上传背景图片并在浏览器中访问该地址时在本地显示。
例如,假设我有这个:
<html>
<head>
</head>
<body>
<input type="hidden" name="MAX_FILE_SIZE" value="500" />
<input type="file" />
</body>
</html>
现在,下一步是什么?这是我想做的:
单击上传按钮。 它上传到我自己的计算机上的以下地址:
file://C:\dummyfolder\images\
看看我得到了什么?我在网上做真正的网页设计,但这是不同的。我有了这个想法,现在我想这么做。请帮忙!
我能想到以前有人这样做过。谷歌在他们的网站上做到了这一点。当您访问 google.com 时,您可以选择要在 Google 上显示的背景图片。它将图像本地存储在您的计算机上。我想这样做,只是在本地存储的网页上,并且该网页存储在本地的url:
file://C:\dummyfolder\dummypage.html
也可以是PHP,没关系。除了我自己的计算机本地之外,它永远不会在任何地方被访问,因此它不必太复杂。
我想要尽可能少的代码。只需一个上传链接,然后它将图像存储在我的计算机上,并在我访问该 html 页面时自动显示为背景。如果我上传另一个图像,它会更改为也存储在本地的新图像,或者它可能会替换旧图像?不知道。
感谢您的帮助!
Make a basic web page, only purpose of the web page is to be able to upload background image and display locally when going to that address in the browser.
For example, say I have this:
<html>
<head>
</head>
<body>
<input type="hidden" name="MAX_FILE_SIZE" value="500" />
<input type="file" />
</body>
</html>
Now, what next? Here is what I want to do:
I click the upload button.
It uploads to my own computer at the following address:
file://C:\dummyfolder\images\
See what I'm getting at? I do real web design online but this is different. I got this idea and now I wanna do it. Please help!
I can think of someone who did this before. Google does it on their site. When you go to google.com you can choose a background image to display on Google. It stores the image locally on your computer. I want to do that, just on a web page that is stored locally, and the web page is stored locally at the url:
file://C:\dummyfolder\dummypage.html
It could be PHP too, it doesn't matter. It will never be accessed anywhere except locally within my own computer so it does not have to be too complicated.
I want the littlest code possible. Just an upload link and then it stores the image on my computer and automatically displays as a background on that html page whenever I visit it. If I upload another image it changes to the new image that is also stored locally or maybe it could replace the old image? Dunno.
Thanks for your help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我相当确定网页无法在客户端 PC 上存储(上传是错误的术语,因为图像永远不会离开您的计算机)。
允许您设置背景图像的网站通常将图像存储在其网络服务器和服务器上。然后将指向您的背景的信息存储在 cookie 或数据库中。 Twitter、谷歌等都使用这种方法。
您也许能够使用一些 HTML5 功能,通过 HTML5 中新的本地存储选项在本地存储图像。您可以在此处选择 W3C 文档: http://dev.w3.org/html5/webstorage/< /a>
I am fairly certain that a web page cannot store (upload is the wrong term here, as the image never leaves your computer) an image on the clients PC.
Sites that allow you to set a background image generally store the image on their webserver & then store information pointing to which background is yours in either a cookie or database. Twitter, google, and many more use this method.
You might be able to use some HTML5 features to store the image locally using the new local storage options in HTML5. You can pick through the W3C docs here: http://dev.w3.org/html5/webstorage/