Shecky
02-06-2003, 11:49 PM
I'd like to alter this code so that the photo uploaded is renamed with the string value of $f_userkey so it comes out like myusername.gif (or.jpg) I'd also like to load a string indicating the file type (.gif or .jpg) into mysql as $picsuffix so i can call it later as
$photoname = /path/dir/.$f_userkey.$picsuffix
Is that retarded? If not... how do i do it?
if (is_uploaded_file($HTTP_POST_FILES['f_photo']['tmp_name'])) {
if ($HTTP_POST_FILES['f_photo']['size']>$max_size) {
error("The file is too big");
}
if (($HTTP_POST_FILES['f_photo']['type']=="image/gif") || ($HTTP_POST_FILES['f_photo']['type']=="image/pjpeg") || ($HTTP_POST_FILES['f_photo']['type']=="image/jpeg")) {
$res = copy($HTTP_POST_FILES['f_photo']['tmp_name'], $imagepath .
$HTTP_POST_FILES['f_photo']['name']);
if (!$res) {
error("upload failed!");
}
}
else {
error("Wrong file type. Please use JPG or GIF");
}
}
$photoname = /path/dir/.$f_userkey.$picsuffix
Is that retarded? If not... how do i do it?
if (is_uploaded_file($HTTP_POST_FILES['f_photo']['tmp_name'])) {
if ($HTTP_POST_FILES['f_photo']['size']>$max_size) {
error("The file is too big");
}
if (($HTTP_POST_FILES['f_photo']['type']=="image/gif") || ($HTTP_POST_FILES['f_photo']['type']=="image/pjpeg") || ($HTTP_POST_FILES['f_photo']['type']=="image/jpeg")) {
$res = copy($HTTP_POST_FILES['f_photo']['tmp_name'], $imagepath .
$HTTP_POST_FILES['f_photo']['name']);
if (!$res) {
error("upload failed!");
}
}
else {
error("Wrong file type. Please use JPG or GIF");
}
}