Jump to content

Archived

This topic is now archived and is closed to further replies.

Flava17

Requesting file variables

Recommended Posts

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 :)

Share this post


Link to post
Share on other sites
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..

Share this post


Link to post
Share on other sites
[!--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 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 :)

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.