【发布时间】:2012-11-09 02:59:07
【问题描述】:
好的,我使用我在 google 上找到的 sn-p 来获取用户上传的图像并将其放在我的目录中的 Content 下
但我担心重复,所以我打算让它作为随机数上传图像
这里是我的代码,你大概可以理解我通过它的目的
<label for="file">Profile Pic:</label> <input type="file" name="ProfilePic" id="ProfilePic" /><br />
<input type="submit" name="submit" value="Submit" />
$ProfilePicName = $_FILES["ProfilePic"]["name"];
$ProfilePicType = $_FILES["ProfilePic"]["type"];
$ProfilePicSize = $_FILES["ProfilePic"]["size"];
$ProfilePicTemp = $_FILES["ProfilePic"]["tmp_name"];
$ProfilePicError = $_FILES["ProfilePic"]["error"];
$RandomAccountNumber = mt_rand(1, 99999);
echo $RandomAccountNumber;
move_uploaded_file($ProfilePicTemp, "Content/".$RandomAccountNumber.$ProfilePicType);
然后基本上在这一切之后,我会尝试让它把那个随机数放入我的数据库中
有人给了我一个新的 sn-p,看起来它会做我想要的,但现在文件并没有一直到我的目录
$RandomAccountNumber = uniqid();
echo $RandomAccountNumber;
move_uploaded_file($ProfilePicName,"Content/".$RandomAccountNumber);
【问题讨论】:
-
是不是有问题隐藏在某处?
-
在将图像保存到没有重复 ID 的目录之前尝试定义图像?
标签: php