I am creating a form that allows a user to upload a image into a specified directory on my server.
Currently when PHP takes this file it renames it into something that makes sense for PHP within a tmp file.
I can then copy the file into a different directory and rename it anything I want.
My question is, is there anyway, to pull the original name.
Right now, I have the person filling out the form, also filling out another field that states image name and image extension (gif or jpg), and then when it copies the file it renames it to this.
There has to be an easier way than this, isn't there?
Below is parts of my code:
This is from my form
<tr>
<td width="150">Image File:</td>
<td><input type="file" name="userfile"></td>
</tr>
<tr>
<td width="150">Image Name:</td>
<td><input type="text" name="imagename" size="28" maxlength="28">.<select name="ext"><option></option><option value="gif">gif</option><option value="jpg">jpg</option></select></td>
</tr>
This is from my executing file
$CID is a hidden field, it just contains a number
I then save $image (the name, not the file) into a database for easy finding later
If ($userfile <> "" AND $imagename <> "" AND $ext <> "") {
copy($userfile, "/home/sites/site44/web/$CID-$imagename.$ext");
$image = "$CID-$imagename.$ext";
}