0
我想上傳圖像到服務器使用PHP和計算使用md5_file相同圖像的散列。但不知何故,它不是指目錄,也不是計算圖像的散列。哈希和上傳圖像文件在同一時間使用PHP
代碼: -
<html><body style="background-color:powderblue;">
<?php
session_start(); //declare you are starting a session
if(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 ...");
}
?>
試過調試你的代碼?而且'md5'不是'md5_file',除了這是一個自定義書面功能 – Akintunde007
發現了這個錯誤。謝謝 。只是想問問是否有任何方法可以再次散列文件和時間戳?哈希(哈希(圖像)。時間戳)在PHP? – user5665780
另外@Akintunde md5_file用於哈希文件https://www.w3schools.com/PhP/func_string_md5_file.asp – user5665780