使用图像哈希在服务器上上传图像,如果图像存在,则使用哈希+日期重命名,并在mysql上传数据

时间:2017-10-17 16:22:35

标签: php mysql

数据未上传到数据库中,但图像已上传,并且不会重命名文件。我是PHP的新手,感谢任何帮助。

$hash is md5() hash of image
$j is hash(hash(image).date)
$newfile = $hash.".".$file_extension;
$l2 is link address.
   if (file_exists($final_dir))
    {
        $newfile =  $j.'.'.$file_ext; //This will rename file with current time stamp which will always unique.
        $l2="$l"."$newfile";
        $hash = $j;
    }

    $upload = move_uploaded_file($filetmp,$final_dir);              //uploading the file to the server

      $select_query = "INSERT   INTO image_table(i_name,i_location,i_hash,image_url) VALUES('$newfile','$final_dir','$hash','$l2')"; // Database query 
            $selected = mysqli_query($connect,$select_query);

0 个答案:

没有答案