how to get image from my device using img tag? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 17

how to get image from my device using img tag?

3rd Nov 2018, 3:40 PM
Ayan Fox
Ayan Fox - avatar
6 Answers
+ 9
The above 2 cases are tedious and unorganised when you are having multiple images ,thus its preferred to go with the 3rd case below 3 ) Organise all the images to a certain folder Create a new folder (say images ) under the folder which contains .html fileCopy all the images to images folderHere no need of lengthy locations just the floder name ( here : images ) a forward slash follwed by image name nd extensionFor exampleĀ <img src= ā€œimages /nissan_gtr.jpg />ā€¦ā€¦ā€¦ā€¦ā€¦ā€¦.In case if u want to publish a image which is alredy in some server just use the url address of it as the value of src attributeThere are also attributes for img tag for like resizing it and all which can be done through css though Thank you,hope u got what u wanted to know Happy Coding šŸ˜‡šŸ˜‡šŸ˜‡šŸ™ŒšŸ™ŒšŸ™ŒšŸ™ŒšŸ™Œ
3rd Nov 2018, 4:44 PM
Asmit joy
Asmit joy - avatar
+ 11
The tag to be used is : <img> You might have seen many html tags which has aĀ opening tagĀ and aĀ closing tag ,Ā image tag doesn't fall into tha category its aĀ Self-closing tag. Syntax : <imgĀ attributesĀ /> Mandatory attribute to be used isĀ srcĀ this attribute specifies the location of the image to the browser. The value for this attribute changes according to the following scenarios 1 ) If the image is in the same folder as the .html file Copy the image u wanna display on the webpage to the same folder where your .html file is located.Add the value to theĀ srcĀ attribute as your image name with its extensionFor example :Ā <img src = ā€œ nissan_gtr.jpgā€ /> 2 ) If the image is in a different folder Right click on the image and go to propertiesCopy the location of the imageChange the back slashes `\` to forward slashes ā€˜/ā€™Use them in src value followed by a forward slash ,image name and extensionFor example :Ā <img src= ā€œ c:/users/xyz/pictures/cars/nissan_gtr.jpg />
3rd Nov 2018, 4:43 PM
Asmit joy
Asmit joy - avatar
+ 6
thanks to everyone for helping me.....šŸ˜ƒšŸ˜ƒ
9th Nov 2018, 1:51 PM
Ayan Fox
Ayan Fox - avatar
+ 5
Use <Img src="imalocation/name.jpg" alt="">
4th Nov 2018, 8:50 PM
Precious Obaseki
Precious Obaseki - avatar
+ 5
When it comes to code not working, it's good to be clear where you are running your code from (e.g. the SoloLearn Code Playground or locally on your laptop / desktop computer, etc.) and where your assets are located (e.g. publicly hosted or privately on your laptop / desktop computer, etc.). Otherwise, it's difficult to know where the disconnect may be occurring. For what it's worth: https://code.sololearn.com/W1HE74c6JmEX/?ref=app
4th Nov 2018, 9:02 PM
Janningā­
Janningā­ - avatar
+ 2
Here is the example. Please use phone device. https://code.sololearn.com/WcSALgsaZKBv/?ref=app in case of desktop you should use another approach
4th Nov 2018, 9:43 PM
Sergei No
Sergei No - avatar