生成唯一的url提交的图片

Generating unique urls to submitted pictures?

本文关键字:提交 url 唯一      更新时间:2023-09-26

这里是网站。

正如你所看到的,我有个人提交的图片,可以通过点击缩略图查看。这都是通过JS完成的。当有人提交一张图片时,如何才能为该图片创建一个具有唯一url的新页面?

提前感谢。请让我知道,如果有任何代码,你需要从我这里。:)

您可以将每个名称更改为随机文件名。(假设您已经使用$imagefilename变量将图像写入一个文件,并且扩展名为.jpg)

<?php
   //The image, defined as $image
   //Write the image to a file, using the $imagefilename variable for a name.
   $webpagefilename = rand();
   $imagefilename = $webpagefilename.".jpg";
   $myFile = $filename.".html";
   $fh = fopen($myFile, 'w') or die("Error: Can't open file");
   $stringData = "<img src='".$imagefilename."' />";
   fwrite($fh, $stringData);
   fclose($fh);
?>

试试。: P