DJ_AM_Juicebox
asked on
POST question
Hi,
I have a php page which creates a form, whose definition looks like:
<form action="index.php?option=c om_ja_subm it" method="post" enctype="multipart/form-da ta" name="adminForm" onSubmit="javascript:setgo od();">
but the 'enctype="multipart/form-d ata' part was messing up sticking all my form parameters into the $_REQUEST array. So I took it out. Now all the form parameters get passed fine to the php page that processes the request.
In the page that processes the post request, I use some functions to upload files like:
move_uploaded_file($_FILES ['image1'] ['tmp_name '], $image1Temp))
will that work ok? I think the original author included the
enctype="multipart/form-da ta"
part in the form definition because files would be uplodaed during processing. Is this true?
In general I'm just trying to:
1) Get filenames from users machine they want to upload (they select that in the form fields).
2) Send the file names to the processing php page
3) Start moving the requested files from the client machine to the server.
Thanks
I have a php page which creates a form, whose definition looks like:
<form action="index.php?option=c
but the 'enctype="multipart/form-d
In the page that processes the post request, I use some functions to upload files like:
move_uploaded_file($_FILES
will that work ok? I think the original author included the
enctype="multipart/form-da
part in the form definition because files would be uplodaed during processing. Is this true?
In general I'm just trying to:
1) Get filenames from users machine they want to upload (they select that in the form fields).
2) Send the file names to the processing php page
3) Start moving the requested files from the client machine to the server.
Thanks
Oh and in addition, for point 3 above: process.php will not be called until the upload is complete, so it won't be "start moving to the server" - more like renaming and storing files on the server.
You should keep multipart/form-data enctype there to get to the files.
It is better to use $_POST to get to your post data, since $_REQUEST structure may change from server to server depending on PHP.INI configuration (order of variables), $_POST order of variables will always be based on the order you have in the form.
It is better to use $_POST to get to your post data, since $_REQUEST structure may change from server to server depending on PHP.INI configuration (order of variables), $_POST order of variables will always be based on the order you have in the form.
Oh and even more - sorry my thinking's coming in dribs and drabs this evening...
you don't nede to do: action="index.php?option=c om_ja_subm it",
you can do:
<form action="index.php" [blah]>
<INPUT Type="Hidden" name="option" value="com_ja_submit">
...
[Blah]
...
</form>
Just to check - what does the JS function actually do? does it modify the form data in any way?
you don't nede to do: action="index.php?option=c
you can do:
<form action="index.php" [blah]>
<INPUT Type="Hidden" name="option" value="com_ja_submit">
...
[Blah]
...
</form>
Just to check - what does the JS function actually do? does it modify the form data in any way?
mit4k is correct about using $_POST instead of $_REQUEST but it will only be an issue if the same variable is passed by more than one of: GET, POST, Cookies
Which is not likely to be the issue in this case. Having said that, best practices are there for a reason :)
Which is not likely to be the issue in this case. Having said that, best practices are there for a reason :)
ASKER
Well inside the form I have a few hidden fields, the one of interest is defined like:
<input type="hidden" name="task" value="blah blah" />
Now in the page that processes the request, I dump the contents of $_POST, $_REQUEST, $_GET, and I will NOT see $task in the any of the arrays.
As soon as I remove the
multipart/form-data enctype
attribute from the form definition though, it comes across just fine. I can't figure out why!
Thanks
<input type="hidden" name="task" value="blah blah" />
Now in the page that processes the request, I dump the contents of $_POST, $_REQUEST, $_GET, and I will NOT see $task in the any of the arrays.
As soon as I remove the
multipart/form-data enctype
attribute from the form definition though, it comes across just fine. I can't figure out why!
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Thanks for the points. Would you mind telling me what the problem was for my own reference?
What exactly is wrong with the contents of $_REQUEST when using multipart/form-data?