Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <center><link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.3/css/all.css" integrity="sha384-SZXxX4whJ79/gErwcOYf+zWLeJdY/qpuqC4cAa9rOGUstPomtqpuNWT9wdPEn2fk" crossorigin="anonymous">				  
<!-- actual upload which is hidden -->
					<input #imageInput  type="file" (change)="incomingfile($event)" id="actual-btn" accept="image/*, .png, .jpg, .jpeg, .pdf" onchange="validateFileType()" hidden/>

					<!-- our custom upload button -->
					<label for="actual-btn">Choose File</label>
					<!-- name of file chosen -->
					<span id="file-chosen">No file chosen</span>
					 <!-- Cancel Button -->
					 <span id="clear" onclick="myFunction()"><i class="fa fa-times"></i></span><center>
              
            
!

CSS

              
                  /* File Choose */
  label {
	background-color: rgb(17, 17, 17);
	color: white;
	display: inline-block;
	width: 7rem;
	height: auto;
	padding: 1rem;
	font-family: sans-serif;
	border-radius: 0.5rem;
	cursor: pointer;
	margin-top: 1rem;
  }

  label:hover{
	  color: #00c2ef;
	  border-left: 4px solid #00c2ef;
  }
  
  #file-chosen{
	margin-left: 0.3rem;
	font-family: sans-serif;
  }
  span i{
padding-left: 1rem;
cursor: pointer;
}
span i:hover{
	color: red;
}
              
            
!

JS

              
                	<!-- Allowed file script start -->
		function validateFileType(){
			var fileName = document.getElementById("actual-btn").value;
			var idxDot = fileName.lastIndexOf(".") + 1;
			var extFile = fileName.substr(idxDot, fileName.length).toLowerCase();
			if (extFile=="jpg" || extFile=="jpeg" || extFile=="png" || extFile=="pdf"){
				//TO DO
			}else{
				alert("Only jpg, jpeg, png and pdf files are allowed!");
			}   
		}


		var fileName = document.getElementById('actual-btn').value.toLowerCase();
if(!fileName.endsWith('.jpeg') && !fileName.endsWith('.jpg') && !fileName.endsWith('.png') && !fileName.endsWith('.pdf')){
    alert('Please upload jpeg, jpg, png, pdf files only.');
    return false;
}
	<!-- Allowed file script end -->

<!-- file script -->
<script>
	const actualBtn = document.getElementById('actual-btn');

const fileChosen = document.getElementById('file-chosen');

actualBtn.addEventListener('change', function(){
  fileChosen.textContent = this.files[0].name
})

<!-- The `multiple` attribute lets users select multiple files. -->
  const fileSelector = document.getElementById('actual-btn');
  fileSelector.addEventListener('change', (event) => {
    const fileList = event.target.files;
    console.log(fileList);
  });
              
            
!
999px

Console