Go Back   Dreamweaver Club Forums > Community Talk > Job Offers and Inquiries
Register FAQ Members List Search Today's Posts Mark Forums Read

Thread Tools Display Modes
Old 11-26-2010, 03:58 PM   #1
Join Date: Oct 2010
Posts: 73
Default Small job - when user uploads file, tell me which user uploaded it


It's only a small job, or atleast I think it is. But i'm just not having any luck with it.

I have an upload script where to get the upload page the user must be logged in. I have the login/logout/register all in place so all my databases are setup, so when the user logs in a session is set - ['username']

What I want to happen is when the user uploads a video file to me, it tells me which username has uploaded the file.

The php code is below:

PHP Code:
// Configuration - Your Options
$allowed_filetypes = array('.avi','.mpg','.flv','.swf','.zip','.wmv','.mp4','.vob','.3g2','3gp','.rm'); // These will be the types of file that will pass the validation.
$max_filesize 12024288// Maximum filesize in BYTES (currently 12MB).
$upload_path '../../onlinestage.co.uk/uploads/'// The place the files will be uploaded to (currently a 'files' directory).
$filename $_FILES['userfile']['name']; // Get the name of the file (including file extension).
$ext substr($filenamestrpos($filename,'.'), strlen($filename)-1); // Get the extension from the filename.
   // Check if the filetype is allowed, if not DIE and inform the user.
'The file you attempted to upload is not allowed.');
// Now check the filesize, if it is too large then DIE and inform the user.
if(filesize($_FILES['userfile']['tmp_name']) > $max_filesize)
'The file you attempted to upload is too large.');
// Check if we can upload to the specified path, if not DIE and inform the user.
'You cannot upload to the specified directory, please CHMOD it to 777.');
// Upload the file to your specified path.
if(move_uploaded_file($_FILES['userfile']['tmp_name'],$upload_path $filename))
'Your file upload was successful, view the file <a href="' $upload_path $filename '" title="Your File">here</a>'// It worked.
'There was an error during the file upload.  Please try again.'// It failed :(.
and this is the form code.

HTML Code:
<form action="/includes/uploader.php" method="post" enctype="multipart/form-data"> <p align="center"> <label for="file">Select a file please:</label> <input type="file" name="userfile" id="file"> <br /> <button>Upload File</button> <p align="center"></form>
I am willing to pay somebody to alter this code for me for a small price as I know it's just a case of a few bits of code that I don't know where to place or what code is needed.
I need to know the username that has uploaded the file, and where abouts would I find out which username has uploaded it?
Please tell me how much you would like to get this done.



my email is josh_everett6@hotmail.co.uk

Last edited by Josh; 11-26-2010 at 04:02 PM..
Josh is offline   Reply With Quote
Old 11-27-2010, 12:56 AM   #2
edbr's Avatar
Join Date: Aug 2005
Location: Bali
Posts: 11,216

just substitute tjis line $newname= "newname". $ext;
with $newname= $_SESSION['username']". $ext;
depending on how its set, this works , tested

// Check if we can upload to the specified path, if not DIE and inform the user.
      die('You cannot upload to the specified directory, please CHMOD it to 777.');
 $newname= "newname". $ext; //

   // Upload the file to your specified path.
   if(move_uploaded_file($_FILES['userfile']['tmp_name'],$upload_path . $newname))
         echo 'Your file upload was successful, view the file <a href="' . $upload_path . $newname . '" title="Your File">here</a>'; // It worked.
         echo 'There was an error during the file upload.  Please try again.'; // It failed :(.
If you're happy and you know it shake your meds!
different style links examples

Flight / Hotel search
Free script download
Bali Villas
edbr is offline   Reply With Quote
Old 11-27-2010, 01:33 AM   #3
Join Date: Oct 2010
Posts: 73

sorry, forget that. just looked, il try it and post back to you,

sorry Ed.


Last edited by Josh; 11-27-2010 at 01:40 AM..
Josh is offline   Reply With Quote
Old 11-27-2010, 01:47 AM   #4
Join Date: Oct 2010
Posts: 73

YESSSSSS! that works Ed, thank you very much.

did have a problem but I think it's ok now.

when I click in my uploads file the file is renamed to the username that uploaded it. If the same username uploads another file, will a different file with the same username be uploaded? i.e. i dont just want it to replace the old one, I want it to upload every file a username uploads.

thanks again Ed

Last edited by Josh; 11-27-2010 at 01:52 AM..
Josh is offline   Reply With Quote
Old 11-27-2010, 01:55 AM   #5
Join Date: Oct 2010
Posts: 73

Hmmm, it does, the file over writes itself. how would I enable multiple files to be uploaded with the same username?




i've done it, i added $filename to the extension list, so now it adds the name of the file onto it too.

thanks Ed, uv been a great help!

Last edited by Josh; 11-27-2010 at 01:59 AM..
Josh is offline   Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT. The time now is 10:17 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2021, vBulletin Solutions, Inc.