Dreamweaver Club Forums

Dreamweaver Club Forums (http://www.dreamweaverclub.com/forum//index.php)
-   Job Offers and Inquiries (http://www.dreamweaverclub.com/forum//forumdisplay.php?f=183)
-   -   Small job - when user uploads file, tell me which user uploaded it (http://www.dreamweaverclub.com/forum//showthread.php?t=38135)

Josh 11-26-2010 03:58 PM

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

edbr 11-27-2010 12:56 AM

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 :(.

Josh 11-27-2010 01:33 AM

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

sorry Ed.


Josh 11-27-2010 01:47 AM

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

Josh 11-27-2010 01:55 AM

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!

All times are GMT. The time now is 10:54 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Copyright 2006 DreamweaverClub.com