Jump to content

Requesting file variables


Flava17

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.