2017-09-06 13 views
0

我需要将图像导入到我的html网站。我不知道要使用什么代码。我的html编码位于名为Nixr的文件夹中。它在我的桌面上。我尝试上传到html网站的咖啡照片也位于名为coffee.jpg的Nixer文件夹中。HTML我想上传保存到我的桌面上的.jpg图像

我已经尝试使用代码:

<img src="/images/html5.gif" alt="HTML5 Icon" style="width:128px;height:128px;"> 

我的HTML编码:

<HTML> 

<HEAD> </head> 

<BODY style="background-color:powderblue;"> 

<br> <br> <br> 

<style> 

div { 
border: 1px solid black; 
margin-top: 0px; 
margin-bottom: 67px; 
margin-right: 210px; 
margin-left: 1000px; 
background-color: powderblue; 
text-align: center; 
} 

</style> 
</head> 
<body> 

<div> 
<h2><b>Log In!</b>.</p> 

<form> 
Login:<br> 
<input type="text" name="username"><br> <br> 
Password:<br> 
<input type="password" name="psw"> 
</form> 
</p> 

<button type="button">Log In!</button> <br> <br> 

<b>Sign Up Today!</b>.</p> 

<form action="/action_page.php"> 
First name:<br> 
<input type="text" name="firstname"> <br> <br> 
Last name:<br> 
<input type="text" name="lastname"> <br> <br> 

<form action="/action_page.php"> 
E-mail: <br> 
<input type="email" name="email"> <br> <br> 

<form action="/action_page.php"> 
Birthday: <br> 
<input type="date" name="bday"> <br> <br> 

<form action=""> 
<input type="radio" name="gender" value="male"> Male 
<input type="radio" name="gender" value="female"> Female 
<input type="radio" name="gender" value="other"> Other 
</form> 

<p>By clicking Create Account, you agree to our Terms and that you <br> have 
read our Data Policy, including our Cookie Use.</p> 

<button type="button">Create Account</button> </h2> 

</div> 
</body> 
</html> 
+0

保存您的html文件的位置? – veera

+0

上传你的代码,以便我们能够理解你到底想要什么......你试过什么......? –

+0

阅读[this](https://www.w3schools.com/html/html_images.asp),你会得到一个想法。 –

回答

0

我不认为你提出这个问题的权利。除非我感到困惑。您不想放弃照片,因为您想使用图片网址让电脑为您找到照片。

我的建议是,你的index.html应该存在于一个文件夹中。在这个例子中,该文件夹的名称是“Site_folder”和图像文件名为“coffee.jpg”

你可以这样使用图片代码:如果您要上传照片

<img src ="site_folder/cofee.jpg" /> 
1

通过文件夹目录中的表单,那么你必须使用PHP。

对于通过形式上传的图像,并显示它是指这个 https://www.w3schools.com/php/php_file_upload.asp

如果你正在寻找刚刚通过HTML显示它,那么你可以使用这个:

<img src="filelocation/filename.jpg" style="height:100px;width:100px;" /> 

如果你的文件目录之外,那么

<img src="../filelocation/filename.jpg" style="height:100px;width:100px;" /> 
0

只要使用此: <img src="name.jpg"> 只需使用您的名字及其扩展名JPG或jpeg。检查图像的细节,如果它在相同的文件夹或相同的地方只使用名称。

0

我想你应该经常在这里知道如何提问。

关于你的问题,

你需要创建你所工作的文件夹中。 将文件index.html(HTML文件)和style.css(CSS文件)保存在该文件夹中。 创建一个子文件夹资源,您需要放置所有图像和.js文件。 这是我遵循的标准。

现在,您可以轻松地调用任何你需要他们使用代码的图片,

<img src="assets/flower.jpg" alt="flower" style="width:100%">

src标签会占用您的图片。

如果图像未加载,alt标签将成为替代显示。

宽度标记将调整放置图像的位置。

欣赏如果有用。

相关问题