php random image file name
Posted
by
bush man
on Stack Overflow
See other posts from Stack Overflow
or by bush man
Published on 2012-11-20T22:40:04Z
Indexed on
2012/11/20
23:00 UTC
Read the original article
Hit count: 153
php
Okay im using a snippet I found on google to take a users uploaded image and put it in my directory under Content
But Im worried about duplicates so I was going have it upload the image as a Random number
well here is my code you can probably understand what im going for through it anyways
<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);
And then basicly after all this Im going try to get it to put that random number in my database
© Stack Overflow or respective owner