PHP Help?
•
8 Sep 2011, 22:37
•
Journals
Im trying to create a little webpage in html and php
but im getting and error
For this script http://pastebin.com/ZJGT0Czi
Im trying to define the "map" variable in dropdown menu in a different page using the following code
http://pastebin.com/pY90Z5rb
can any help me getting the files uploaded to the folder defined in the dropdown menu?
but im getting and error
For this script http://pastebin.com/ZJGT0Czi
Im trying to define the "map" variable in dropdown menu in a different page using the following code
http://pastebin.com/pY90Z5rb
can any help me getting the files uploaded to the folder defined in the dropdown menu?
$_POST["map"] will have the content of that.
pls kill me for missing that ; :p
for some reason, the file isnt being uploaded to the folders i created
Make sure the directory exists relative to the file executed
And another problem, your select is outside your form so if you want to send a value of that select to server with it, move select before form closing tag.
EDIT: Another issue you can experience, you should set a value attribute on select options otherwise you wont have anything in $_POST['map'] variable
Im not learning php at school yet, but i cant wait
can you help me :<?
thx for your help so far btw
edit:
<select name="$map" size="1">
<option>C/</option>
<option>Computertechniek/</option>
<option>Databases en SQL/</option>
</select>
<form enctype="multipart/form-data" action="upload.php" method="POST">
Please choose a file: <input name="uploaded" type="file" /><br />
<input type="submit" value="Upload" />
</form>
Please choose a file: <input name="uploaded" type="file" /><br />
<input type="submit" value="Upload" />
<select name="map" size="1">
<option>C/</option>
<option>Computertechniek/</option>
<option>Databases en SQL/</option>
</select>
</form>
thats what I ment by putting select into form, everything outside <form></form> will not be sent to server after submit.
Another thing is, you cant assing name of "$map" for inputs, leave it as it was ( name="map"). Your problem with $_POST['map'] not being assigned lies in smth else. As I said, you need to specify values for your options withing select. To give you an example:
<select name="map" size="1">
<option value="1">C/</option>
<option value="2">Computertechniek/</option>
<option value="3">Databases en SQL/</option>
</select>
will send to server variable "map" with value specified by selected option (so $_POST['map'] will hold a value in option). So, if you wont have attribute value present in options, it wont sent a value, thus variable is defacto not sent at all (if you specify value as value="" it will send empty string and variable will be set!! so, no value attribute = no variable, empty attribute = variable holding emptry string). Full example of your form would look like this:
<form enctype="multipart/form-data" action="upload.php" method="POST">
Please choose a file: <input name="uploaded" type="file" /><br />
<input type="submit" value="Upload" />
<select name="map" size="1">
<option value="C/">C/</option>
<option value="Computertechniek/">Computertechniek/</option>
<option value="Databases en SQL/">Databases en SQL/</option>
</select>
</form>
EDIT: or maybe I can be wrong about selects, I actually didnt test whether option with no value attribute is sending innerHtml as value or not (it seems kinda logical to me that no value does basically nothing, but seeing that attribute value is optional, I am not sure right now), but its always nice to follow good programming practices, it will save a lot of troubles in future.
I already used
<option value="C/">C</option>
<option value="Computertechniek/">Computertechniek</option>
<option value="Databases en SQL/">Databases en SQL</option>
to make it look better
thx for your help, I guess I need to learn a lot more from tutorials etc before I start a new project
I mispasted the select(pasted it above the form)
semicolon ;P
not crossfire.
oh sorry BM
You could use class...
http://genert.impact.pri.ee/upload.phps