![]() |
#1 |
![]() Join Date: Oct 2010
Posts: 73
|
![]() Hi,
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:
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 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. Thanks, Josh my email is josh_everett6@hotmail.co.uk Last edited by Josh; 11-26-2010 at 04:02 PM.. |
![]() |
![]() |
![]() |
#2 |
![]() ![]() 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 Code:
// Check if we can upload to the specified path, if not DIE and inform the user. if(!is_writable($upload_path)) 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. else 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 |
![]() |
![]() |
![]() |
#3 |
![]() Join Date: Oct 2010
Posts: 73
|
![]() sorry, forget that. just looked, il try it and post back to you,
sorry Ed. Josh Last edited by Josh; 11-27-2010 at 01:40 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.. |
![]() |
![]() |
![]() |
#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?
thanks, Josh EDIT 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.. |
![]() |
![]() |
![]() |
Thread Tools | |
Display Modes | |
|
|