Answers for "uploading file"

PHP
1

basic code for file upload in php

//This is the minimal code for an image upload for first time learners
//html portion
<!DOCTYPE html>
<html>
<head>
	<title>ImageUpload</title>
</head>
<body>
	<form action="upload.php" method="post" enctype="multipart/form-data">
		<label>Username</label>
		<input type="text" name="username">
		<br>
		<label>UploadImage</label>
		<input type="file" name='myfile'>
		<br/>
		<input type="submit" value="upload">
	</form>
</body>
</html>
  
 //php portion
  <?php
	$user=$_POST['username'];
	$image=$_FILES['myfile'];
	echo "Hello $user <br/>";
	echo "File Name<b>::</b> ".$image['name'];

	move_uploaded_file($image['tmp_name'],"photos/".$image['name']);
	//here the "photos" folder is in same folder as the upload.php, 
	//otherwise complete url has to be mentioned
	?>
Posted by: Guest on July-03-2020
2

file upload

uploadFile(e){
    const file = e.target.files[0];
    storage.ref('images/'+ file.name).put(file)
      .then(response => {
        response.ref.getDownloadURL().then((downloadURL) => {
           firebase.database().ref(YOUR_DATABASE).child(THE_USER_ID).update({imageUrl:downloadURL})
      }                 
     .catch(err => console.log(err))
}
Posted by: Guest on May-18-2021
0

syntax for uploading a file

Public void fileUpload(Stirng path){ 
WebELement upload = driver.findELement; Upload.sendKeys(path)
} 
• We need to locate the upload button in html. 
• The element will have tag input. 
• Then we do sendKeys by passing the path to file which we want to upload
Posted by: Guest on June-15-2021

Code answers related to "uploading file"

Browse Popular Code Answers by Language