Flava17 Posted March 15, 2006 Share Posted March 15, 2006 I've been working with PHP for a while and come across a problem.My web server doesn't allow me to use variables across pages, unless I use $file = $_REQUEST['file'];This isn't a problem - however when I try to use a <input type="file" name="img"> type for a form, I cannot seem to request the variables sent. I want to use this for an upload form - and PHP should create the variables $img_size, $img_name, $img_type automatically. However it does not.I cannot edit php.ini as I think it's on my hosts server, which I can't access?? I'm not too sure.. This is the script that I have quickly made:[b]<?$img = $_REQUEST['img'];$img_name = $_REQUEST['img_name'];echo($img);echo($img_name);?><br><br><form method="POST" action="test.php" enctype="multipart/form-data"><input type="file" name="img"><br><br><input type="submit" value="Go!"></form>[/b]Any help would be appreciated :) Quote Link to comment https://forums.phpfreaks.com/topic/5014-requesting-file-variables/ Share on other sites More sharing options...
logu Posted March 15, 2006 Share Posted March 15, 2006 Hi, You should use $_FILE['file'] to get itin HTML form tag you can useenctype='multipart/form-data' to get all the informations clearly<form enctype='multipart/form-data' method=''>Regards.. Quote Link to comment https://forums.phpfreaks.com/topic/5014-requesting-file-variables/#findComment-17710 Share on other sites More sharing options...
Flava17 Posted March 15, 2006 Author Share Posted March 15, 2006 [!--quoteo(post=355243:date=Mar 15 2006, 02:14 AM:name=logu)--][div class=\'quotetop\']QUOTE(logu @ Mar 15 2006, 02:14 AM) [snapback]355243[/snapback][/div][div class=\'quotemain\'][!--quotec--]Hi, You should use $_FILE['file'] to get itin HTML form tag you can useenctype='multipart/form-data' to get all the informations clearly<form enctype='multipart/form-data' method=''>Regards..[/quote]Thanks for the help but I still can't seem to get it to work.. I already used the enctype attribute by the way. If you could tell me how to retrieve $img_name, $img_size .etc that'd be great :)Nevermind I got it to work using:$img_name = $_FILES['img']['name'];Thanks for the help :) Quote Link to comment https://forums.phpfreaks.com/topic/5014-requesting-file-variables/#findComment-17716 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.