Chappers Posted July 11, 2006 Share Posted July 11, 2006 HiI'm using this simple upload form to upload image files to a folder on my server, and I'm trying to add another form input in the form of a text input. I wanted to have this text input added to the first part of an uploaded file's name so I know who's sent it, but I can't work out how to do it. I've tried and tried, and I've searched the net but it's not easy to search for.[code]<?phpif(!isset($_POST['upload'])) {echo '<form name="upload" enctype="multipart/form-data" method="POST" action="'.$_SERVER['REQUEST_URI'].'"><input type="file" name="file" value=""><br>Name: <input type="text" name="name" size="20"><br><input type="submit" name="upload" value="Upload"></form>';} else {$yourdomain = 'http://example.net/';$uploaddir = 'files/';$filename = $_FILES['file']['name'];$filesize = $_FILES['file']['size'];$tmpname_file = $_FILES['file']['tmp_name'];$date_file = date(dmY);if($filesize > '102400') {echo "File is too big!";} else {move_uploaded_file($tmpname_file, "$uploaddir$date_file$filename");echo "File uploaded Successfully.<br />URL to your file: <a href=\"http://example.net/".$uploaddir.$date_file.$filename."\"> http://example.net/".$uploaddir.$date_file.$filename."</a>";} }?>[/code]The field I've added can be seen above as :[code]Name: <input type="text" name="name" size="20">[/code]Could someone please tell me how I pass this to be added to the file's name? I can work out what to do once I've made it a variable ($blahblah) but don't know how to make it one. I assumed it had to be done in the section of code where the $filename, $filesize are done...Thanks Quote Link to comment https://forums.phpfreaks.com/topic/14273-how-do-i-make-this-form-input-into-a-variable/ Share on other sites More sharing options...
kenrbnsn Posted July 11, 2006 Share Posted July 11, 2006 That field would be returned to your script in $_POST['name']Ken Quote Link to comment https://forums.phpfreaks.com/topic/14273-how-do-i-make-this-form-input-into-a-variable/#findComment-56127 Share on other sites More sharing options...
Chips Posted July 11, 2006 Share Posted July 11, 2006 for filename, try:[code]$filename = $_POST['name'] . $_FILES['file']['name'];[/code]Not tried, just guessing :) Quote Link to comment https://forums.phpfreaks.com/topic/14273-how-do-i-make-this-form-input-into-a-variable/#findComment-56179 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.