matt.sus@gmail.com wrote:
: hi i have a website where people can register their details and upload
: a pic.
: so i have variables for firstName and lastName etc
: not the following lines are in the php file that everything gets sent
: to:
: copy($HTTP_POST_FILES['uploadPhoto']['tmp_name'],
: $HTTP_POST_FILES['uploadPhoto']['name']);
: print "<h2>Thank you for registering.</h2><br>";
: print "<h2>Your details have been saved on our system.</h2>";
: print "<br>"
: All the variables go nicely into the mysql database and the photo
: uploads, however it just uploads with the name the person has it saved
: on their computer as.
: Is there a way to ammend the above to rename the photo they are
: uploading as their firstName and lastName.
If you already have the name in some variables, then just go ahead and
use them.
$name_for_save_as = "$firstName-$lastName.jpeg";
copy($HTTP_POST_FILES['uploadPhoto']['tmp_name'],$name_for_save_as);
HOWEVER, you should also do something to make sure the file name is a good
name. Read the php docs for functions to help do that, but basically
something like
$name_for_save_as = escape($firstName) . escape($lastName) . ".jpeg";
(but the "escape" function may not be the function you want to use for
this)
Many sites allocate a unique serial number for things like files. The
database entry for a person would then save the serial number so you know
which file to use for that person.
--
This space not for rent.