phpupload

 <!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta http-equiv="X-UA-Compatible" content="IE=edge">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Document</title>

</head>

<body>

    <form action="upload.php" method="post" enctype="multipart/form-data">

<input type="file" name="f" id="">

<button type="submit">upload</button>

    </form>

</body>

</html>



<?php

//include connection page here

/*Php.ini

/*upload_max_filesize=40M


; Maximum number of files that can be uploaded via a single request

max_file_uploads=20*/

$f=$_FILES["f"];

//print_r($f);

$filename=$_FILES['f']['name'];

$filetype=$_FILES['f']['type'];

$filetmp_name=$_FILES['f']['tmp_name'];

$filesize=$_FILES['f']['size'];

$fileextension=explode('.',$filename);

//print_r($fileextension[1]);

$fileextension= strtolower(end($fileextension));

//echo $fileextension;

$allwoedextension=array('jpg','doc','html');


if(in_array($fileextension,$allwoedextension))

{

    $dest_path='upload_files/'.$filename;

   if( move_uploaded_file($filetmp_name,$dest_path))

   {

echo "file uploaded successfully";

//inser query insert into tabelname (coloumn names) values(....);

//query execute

   }

   else{

       echo "file not uploaded";

   }

//echo "file uplaod";

}

else {

    echo "u can upload only jpg doc and html file";

}

?>

Comments

Popular posts from this blog

interview questions js[ Anurag Singh ProCodrr]

reactnative_creation