Change file name
Moderator: General Moderators
Change file name
I want to upload my picture and change that file (picture) name same as my login. This mean everybody can upload their picture when they login into my system and the picture will be saved in 1 folder. Let say my picture's file name is 'johnphillip' and my login is 'john'. So I want to save this picture using 'john' as a name in that folder after uploaded. Any idea pls...
Change file name
Ok. Let me do session part first and then we'll continue. I'll be back..
Change file name
Ok. I've create a session and can hold the login and password value to any page. After that, what should I do?
Change file name
Anybody can help me pls...
Change file name
Maybe too difficult I think, at least for me... 
-
malcolmboston
- DevNet Resident
- Posts: 1826
- Joined: Tue Nov 18, 2003 1:09 pm
- Location: Middlesbrough, UK
- andre_c
- Forum Contributor
- Posts: 412
- Joined: Sun Feb 29, 2004 6:49 pm
- Location: Salt Lake City, Utah
Try this
Try something like this:
- An upload form:
- Form Handler Page:
- An upload form:
Code: Select all
<form action="formhandler.php" enctype="multipart/form-data" method="post">
<input type='file' name='loginpic' />
<input type='submit' name='imgupload' value='Send Picture' />
</form>Code: Select all
<?
if (isset($_REQUEST['imgupload'])) {
$pic_dir_name = '/path/to/image/'.$_SESSION['login_name'].'.jpg';
if (is_uploaded_file($_FILES['loginpic']['tmp_name'])) {
copy($_FILES['loginpic']['tmp_name'], $pic_dir_name);
} else {
echo "Image Upload Failed. Filename: " . $_FILES['loginpic']['name'];
}
}
?>