Jump to content


Photo

Requesting file variables


  • Please log in to reply
2 replies to this topic

#1 Flava17

Flava17
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 15 March 2006 - 06:57 AM

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:

<?


$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>


Any help would be appreciated :)

#2 logu

logu
  • Members
  • PipPipPip
  • Advanced Member
  • 32 posts

Posted 15 March 2006 - 07:14 AM

Hi,
You should use
$_FILE['file'] to get it


in HTML form tag you can use
enctype='multipart/form-data' to get all the informations clearly

<form enctype='multipart/form-data' method=''>


Regards..

#3 Flava17

Flava17
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 15 March 2006 - 07:36 AM

[!--quoteo(post=355243:date=Mar 15 2006, 02:14 AM:name=logu)--][div class=\'quotetop\']QUOTE(logu @ Mar 15 2006, 02:14 AM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Hi,
You should use
$_FILE['file'] to get it
in HTML form tag you can use
enctype='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 :)





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users