2017-09-06 64 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標籤將成爲替代顯示。

寬度標記將調整放置圖像的位置。

欣賞如果有用。

相關問題