Quantcast
Channel: Hash and upload an image file at the same time using php - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Hash and upload an image file at the same time using php

$
0
0

I am trying to upload an image to a server using PHP and calculate the hash of the same image using md5_file. but somehow it is not referring to the directory either and not calculating the hash of the image.

Code:-

<html><body style="background-color:powderblue;"><?phpsession_start(); //declare you are starting a sessionif(isset($_POST['submit'])){    include'connect.php';    $fname = $_POST['fi'];    $filename = $_FILES['fileupload']['name'];    $filetmp = $_FILES['fileupload']['tmp_name'];    $filesize = $_FILES['fileupload']['size'];    $file_basename = basename($_FILES['fileupload']['name']);    $dir = "upload/";    $final_dir = $dir.$file_basename;    $hash = md5_file($final_dir);       $_SESSION['hash'] =$hash;    $upload = move_uploaded_file($filetmp,$final_dir);}/* image_name= "$file_basename";    image_path ="$final_dir";*/    /*Database Query*/**strong text**        if($filesize > 1024000){            echo("Greater then expected");            }if($selected){    echo nl2br("Operation successful\n");    echo nl2br("URL Record successfully\n");    echo nl2br("$fname \n \n");    }else{    echo("No No No ...");}?>

Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images