drivethru Posted September 19, 2006 Share Posted September 19, 2006 Hey, I have an upload system on my website that allows people to upload files to the site. I have added a username/password system to the site since then. Users have to login to upload a video. Usernames are stored in a mySQL database. When users upload a file, how can I get their username shown to me so I know who sent me the file? Quote Link to comment Share on other sites More sharing options...
redarrow Posted September 19, 2006 Share Posted September 19, 2006 [code]<?php session_start();?><input type="hidden" name="<?php echo $name;?>">[/code]add a colum called names to the upload colum. Quote Link to comment Share on other sites More sharing options...
drivethru Posted September 19, 2006 Author Share Posted September 19, 2006 Thanks, but I'm still not real sure of what I'm supposed to do. Do I place that code in my "upload.php" or somewhere else and where will the name show up at? Quote Link to comment Share on other sites More sharing options...
drivethru Posted September 19, 2006 Author Share Posted September 19, 2006 If this helps any, I'm using Simplicity oF Upload to upload my files. It sends me an email when a file is uploaded anyway. How can I get the username to show up in the email? Quote Link to comment Share on other sites More sharing options...
Zane Posted September 19, 2006 Share Posted September 19, 2006 I think the best idea for this would be to add the users ID number to the beggining of the filenamelike if my ID is 9893and the file I uploaded is called tree.jpgset you code to rename it to 9893_tree.jpgthen you more systematically get the corresponding user Quote Link to comment Share on other sites More sharing options...
drivethru Posted September 20, 2006 Author Share Posted September 20, 2006 That sounds like a really good idea. How do I get it to rename the file? Sorry, I'm still new to PHP. Quote Link to comment Share on other sites More sharing options...
Zane Posted September 20, 2006 Share Posted September 20, 2006 well, what does your code look like so farshow us some code and we can help you mold it to what you need. Quote Link to comment Share on other sites More sharing options...
drivethru Posted September 21, 2006 Author Share Posted September 21, 2006 Here's what I have on my page to check to see if the user is logged in.[code]<?phprequire 'db_connect.php';if ($logged_in == 0) { die('Sorry you are not logged in, this area is restricted to registered members. <a href="login.php">Click here</a> to log in.');}// show content$db_object->disconnect();// when you are done.?>[/code]Here is my uploaderI also have a configuration file[code]<?phprequire_once('SFUConfig.php');require_once('functions.php');if (SFU_CHANGE_LNG === true and isset($_GET['language'])) { $temp_language = strtolower($_GET['language']); if (!file_exists("$temp_language.lng")) { require_once("$language.lng"); echo "($temp_language.lng) $txt[lng_doesnot_exist]<br />"; echo $txt['lng_fall_default']; } else { $language = $temp_language; }}require_once("$language.lng");$keys = array_keys($allowed);foreach($keys as $one) if (!in_array(strtolower($one), array('text', 'exec', 'image', 'package'))) { html_header(); echo '<p align="center"><span style="color:red; font-size: 12pt;"><b>'.$txt['unknown_attr'].': '.$one.'<br />'.$txt['unknown_notify'].'</b></span></p>'; html_footer(); exit; }if (SFU_CHANGE_NUM === true && isset($_GET['num_files']) && is_numeric($_GET['num_files'])) $num_files = (int)$_GET['num_files'];foreach($allowed as $notyet) foreach($notyet as $final) $flat_allowed[] = strtolower($final);html_header();if (SFU_PROTECT == true) { session_start(); if (isset($_POST['SFU_Protect'])) { if ($_POST['SFU_Protect'] == SFU_PASSWORD) $_SESSION['SFU_Protect'] = SFU_PASSWORD; else { echo $txt['pass_wrong']; html_footer(); exit; } } elseif (!isset($_SESSION['SFU_Protect'])) { protectForm(); html_footer(); exit; } elseif ($_SESSION['SFU_Protect'] !== SFU_PASSWORD) { session_unset(); session_destroy(); }}if (isset($_POST['SFUsubmit'])) { for ($i = 0; $i < $num_files; $i++) { if ($_FILES['SFUfile']['name'][$i] == '') continue; $File = strtr(stripslashes($_FILES['SFUfile']['name'][$i]), '\'" |\\/?!*#', '__________'); $dotpos = strrpos($File, '.'); $length = strlen($File); $ext = strtolower(substr($File, -($length - $dotpos - 1))); $noext = substr($File, 0, -($length - $dotpos - 1)); if (!in_array($ext, $flat_allowed)) { LogErrors("{$txt['extension']} <b>$ext</b> {$txt['not_allowed']}"); continue; } switch($_FILES['SFUfile']['error'][$i]) { case 0: break; case 1: LogErrors($txt['PHP_file_size']); continue 2; break; case 2: LogErrors("$txt[file_size] $txt[exceded_limit]"); continue 2; break; case 3: LogErrors($txt['partial_upload']); continue 2; break; case 4: LogErrors($txt['no_file']); continue 2; break; } if ($_FILES['SFUfile']['size'][$i] > (SFU_MAXSIZE * 1024)) { LogErrors($txt['file_size'].' ('.round($_FILES['SFUfile']['size'][$i]/1024, 2)." $txt[KB]) {$txt['not_allowed']}"); continue; } $fullname = SFU_REALPATH.$File; if (!isset($content)) $content = ''; if (SFU_OVERWRITE == false or !isset($_POST['SFUoverwrite'])) { if (file_exists($fullname)) { LogErrors($txt['file_exists']); continue; } if (isset($allowed['exec']) and in_array($ext, $allowed['exec'])) { if ($ext == 'php' and $highlight_php == true and file_exists(SFU_REALPATH.$noext.'html')) { LogErrors($txt['exec_file_exists']); continue; } elseif (file_exists(SFU_REALPATH.$noext.'txt')) { LogErrors($txt['exec_file_exists']); continue; } } } if(@move_uploaded_file($_FILES['SFUfile']['tmp_name'][$i], $fullname)) { if (isset($allowed['image']) and in_array($ext, $allowed['image'])) is_image(); elseif (isset($allowed['text']) and in_array($ext, $allowed['text'])) is_text(); elseif (isset($allowed['exec']) and in_array($ext, $allowed['exec'])) is_exec(); elseif (isset($allowed['package']) and in_array($ext, $allowed['package'])) $uploaded[] = $File; if ($change_mode == true) @chmod($fullname, $mode)or LogErrors($txt['chmod_fail']); } else { LogErrors($txt['move_failiur'].'<br />'.$txt['try_again']); if (!file_exists(SFU_REALPATH)) echo '<span style="color:red; font-size: 12pt;"><b>'.$txt['doesnot_exist'].'</b></span><br />'; elseif (!is_writable(SFU_REALPATH)) echo '<span style="color:red; font-size: 12pt;"><b>'.$txt['unwritable'].'</b></span><br />'; } } if ($show_error_log == true and isset($errors) and count($errors) > 0) ShowErrorLog($errors); if ($show_uploaded_list == true and isset($uploaded) and count($uploaded) > 0) ShowUploaded($uploaded); if (isset($content)) echo $content; if ($show_upload_form == true) PrintForm(); if ($notify_admin == true) MailUploaded(); if ($log_upload == true) FilesLogging();} else PrintForm();html_footer();clearstatcache();?>[/code][b]EDITED by ZANUS - Try and use the code tags for such long code or any at that[/b] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.