Pass Cookie value into filename field of file upload Form
Posted: Wed Jun 13, 2007 9:21 am
feyd | Please use
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I am developing a PHP script that will allow registered users to upload a very small jpg picture. This picture is then processed (reduced to a certain size). The original file, after being processed, has to be renamed. The new name will be the username (plus the filename extension *.jpg). The processed and renamed file will be stored on the server. The link to this file will be put into a database.
Whenever a user logs in to the site, the username.jpg picture will be retrieved and displayed. There will be several hundred users. Filesize will be around 20k. The first step here is to allow users to upload the file. I already have a working script that checks if the user is logged in (by reading a cookie) and authenticated by checking username/password against a database. I also have the script for resizing the picturem, checking file siz and type.
[color=brown]What I need help with is:[/color]
When the user uploads a picture, I want the filename to be changed from what it is originally to what I want it to be (which is $username.jpg). How do I incorporate that into the Form for uploading? The problem I am having is: the COOKIE containing the username has to be incorporated into the form below i.e. [color=brown]name="nameoffile" to be replaced with name=$_COOKIE[usernamecookie][/color], or something similar to that. Can this be done?? I tried different ways of doing it, but doesn't work. Would appreciate any help. Thanks!!Code: Select all
<?php
echo '
<form method="POST" action="'.$_SERVER['PHP_SELF'].'" enctype="multipart/form-data">
<input type="file" name="nameoffile">
<input type="Submit" name="Submit" value="Submit">
</form>';
?>feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]