html - How can I use a $_POST variable as part of a file path on a different page - PHP -


I am quite new in PHP.

I have a problem with a file upload page that I am making. Actually, I have a drop down box with a list of categories in the file upload form, the user browses and selects a file, and then selects a category before submitting the file.

The file is supposed to be dynamically uploaded to a folder on folders by the server (user_data / username / fileType / filename) but what I'm actually receiving (user_data / username // filename)

I am passing the drop down list variable as $ _POST, but for some reason I can not get it to populate the file path. I'm sure its some simple but I'm stuck. Here is my code

fileupload.php

  & lt; Html & gt; & Lt ;? Php if (isset ($ _ POST ["file"])) {$ selected = $ _POST ["fileType"]; } // $ selected = $ _POST ['fileType']? & Gt; & Lt; Form action = "upload_file.php" method = "post" encrypt = "multipart / form-data" & gt; & Lt; Label = "file" & gt; Filename: & lt; / Label & gt; & Lt; Input type = "file" name = "file" id = "file" & gt; & Lt; Br> & Lt; Br / & gt; & Lt; Label = "docType" & gt; File type: & lt; / Label & gt; & Lt; Select name = "file type" id = "file type" & gt; & Lt; Option value = "0" selected = "selected" & gt; Choose upload file type: & lt; / Option & gt; & Lt; Option value = "Evac_Dgm" & gt; Exhaust diagram & lt; / Option & gt; & Lt; Option value = "Evac_Man" & gt; Exit Manual & lt; / Options & gt; & Lt; Option pvalue = "warden_list" & gt; Warden list & lt; / Option & gt; & Lt; Option value = "Att_Record" & gt; Attendance Record & lt; / Option & gt; & Lt; / Select & gt; & Lt; Br / & gt; & Lt; Br / & gt; & Lt; Input type = "submit" name = "submit" value = "submit" & gt; & Lt; / Form & gt; & Lt; / Html & gt;  

==============

upload_file.php

  & lt ;? Php echo $ _POST ['filetype']; Permission $ $ Exits = Array ("GIF", "JPG", "JPG", "PNG", "PDF"); $ Temp = Explosion (".", $ _FILES ["file"] ["name"]); $ Extension = end ($ temp); If (($ $ _FILES ["file"] ["type"] == "image / gif") ($ _FILES ["file"] ["type"] == "image / JPEG") || ($ $ _FILES ["file"] ["type"] == "image / JPG") ($ _FILES ["file"] ["type"] == "image / PJPAG") ($ _FILES ["file" ] ["Type"] == "image / x-png") ($ _FILES ["file"] ["type"] == "image / PNG") ($ _FILES ["file"] ["type"] == "App / PDF") & amp; amp; ($ _FILES ["file"] ["size"] 2000000) & amp; amp; in_array ($ extension, get permission $) {if ($ _FILES [ "File"] ["error"]> gt; 0) {resonant "code of return:" $ _FILES ["f Ile "] [" error "]." & Lt; br & gt; ";} and {$ session = $ _SESSION ['username']; $ $ selected = $ _POST ['fileType']; echo" upload Do: "$ _FILES [" file "] [" name "]" & lt; br & gt; "echo" type: "$ _FILES [" file "] [" type "]" & lt; br & gt; "" Size: "echo ($ _FILES [" file "] [" size "] / 1024)." KB 
"resonant" temp file: "$ _FILES [" file "] [" Tmp_name "]" & lt; br & gt; "; if (file_exists (" user_data ". $ Session "/". $ _POST ['fileType'] "/". $ $ _FILES ["file"] ["name"])) {echo $ _FILES ["file"] ["name"] "already exists."; } Else {move_uploaded_file ($ _ FILES ["file"] ["tmp_name"], "user_data /". $ Session. $ /_POST ['fileType'] ./ ". $ $ _FILES [" file "] ["Name"] ":" echo "user base - content /". $ Session "/" $ _POST ['file type']. "/" $ _FILES ["file"] ["name" ];}}} And {echo "invalid file";}?

Any help you can give to people will be horrible

Change your