Put the Following Function here: <?php function uploadimgfile($index,$folder="other",$prefix="other") { $target_dir = "upload_directory_path/"; // try to put full physical path // identity accstatement address advtimg other $uploadOk = 1; $senddata = array(); $senddata['data'] = "NILL"; $notallowed = array("php","js","css","html"); // defined here the extesion not to upload $shownotallowed = "PHP, JS, CSS, HTML fie is not allowed to upload."; $extension = explode(".",basename($_FILES[$index]["name"])); $extension = end($extension); ECHO "<hr/>" . $realfilnename = basename($_FILES[$index]["name"]); $datetofolder = date("Y/M/d"); $datetofolder = strtolower($datetofolder); $checkdirectory = $targ
Create The HTML Form Create an HTML form, so you can choose file want to upload: *********************** Code *********************** <form action="upload.php" method="post" enctype="multipart/form-data"> Please choose a file: <input type="file" name=" uploadFile " accept="image/*" /> <br> <input type="submit" value="Upload File" /> </form> *********************** End of Code *********************** On the Above code accept is use for accepting only Image file as a File Input. If no accept is specify, All File are accepted. Create a upload.php file , whose code will be as Follow: *********************** Code *********************** ?php $target_dir = "uploads/"; $target_dir = $target_dir . basename( $_FILES["uploadFile"]["name"]); $uploadOk=1; // Check if file already exists if (file_exists($
Comments
Post a Comment