UPLOAD FILE USING PHP
Php file upload single and multiple file supported simple codes Php
file upload features allows to upload text, binary files full control over the file to be uploaded
through php authentication & file operation functions
Steps :
Form tag add Enctype Attribute Enctype=”multipart/form-data”
Use File Uploaded Function
Move_uploaded_file
MY Directory
Upload The File
Coding
<html>
<head><style>.col {
width: 100%;
height: 80%;
magin:0 auto;
}
#s1{
padding: 10px;
border-radius: 6px;
background-color: #4683ea;
width:100px;
color:white;
}
.background-card h4 {
padding-bottom: 0.5em;
margin-bottom: 0.5em;
margin-top: 1em !important;
}
h4 > .fa {
display: none !important;
}
.card-nested {
padding: .5rem 0 .5rem 0;
}
.labels {
display: inline;
}
.skill-info {
margin-left: 0;
}
blockquote {
font-size: 100%;
}
}
#s{
background: radial-gradient(royalblue,skyblue)
}
#nam{
background: transparent;
font-size: 35px;
font-weight: 800;
border: none;
color: #000000;
}
#nm::placeholder{
color: #000000;
font-size: 35px;
font-weight: 700;
}
.form-control:focus {
background-color: #fff;
outline: 0;
box-shadow: none;
}
.form-control{
padding: .375rem 0px;
}
.as::placeholder{
opacity: 0.2;
}
#skl{
background: transparent;
font-size: 17px;
border: none;
font-weight: 700;
color: #77b6e9;
}
#skl::placeholder{
color: #000000;
font-size: 17px;
font-weight: 700;
color: #77b6e9;
}
#eml{
background: transparent;
font-size: 13px;
border: none;
font-weight: 400;
}
#eml::placeholder{
color: #000000;
font-size: 13px;
font-weight: 400;
}
#pno{
background: transparent;
font-size: 12px;
border: none;
font-weight: 400;
}
.ui-datepicker-calendar {
display: none;
}
#pno::placeholder{
color: #000000;
font-size: 12px;
font-weight: 400;
}
</style></head>
<form method="post" action="" enctype="multipart/form-data">
File<input type="file" name="f1"><br>
<input id="s1" type="submit" name="s" value="upload">
</form><br>
<div class="col">
<ul type="none">
</html>
<?php
$con=mysqli_connect("localhost","root","","test");
if(isset($_POST['s'])){
$fname=$_FILES['f1']['name'];
$dir=$_FILES['f1']['tmp_name'];
$ext=pathinfo($fname,PATHINFO_EXTENSION);
if($ext=="png" || $ext=="jpg" || $ext=="gif"){
move_uploaded_file($dir,"image/".$fname);
$sql="insert into image values('$fname')";
$con->query($sql);
$con->query($sql);
No comments:
Post a Comment