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 gtc: field. : & lt; select name = "file type" id = "fileType"> to: & lt; Name select Here are some more comments for your HTML code: & quot; File type & quot; id = "fileType" & gt; Lt;! - Do you want to type & lt; label = "fileType">? - & gt; & lt; label = "docType" & gt; File type: & lt; / label & gt; & lt; = "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 ;! - You have a typo below, should be & lt; Option value = "... (is an additional 'p') -> gt; option = p = = warden_list" & gt; Warden list & lt; / Option & gt; & Lt; Option value = "Att_Record" & gt; Attendance Record & lt; / Option & gt; & Lt; / Select & gt;
Get link
Facebook
X
Pinterest
Email
Other Apps
Comments
Post a Comment
Popular posts from this blog
eclipse plugin - Run java code error: Workspace is closed -
July 15, 2012
To create an automated project, I created a plug-in project with the following dependencies: Org.eclipse.core.resources org.eclipse.equinox.registry org.eclipse.core.runtime and the following The Java class is located in the src folder: Package Examiner; Import org.eclipse.core.resources.IProject; Import org.eclipse.core.resources.IWorkspaceRoot; Import org.eclipse.core.resources.ResourcesPlugin; Import org.eclipse.core.runtime.CoreException; Import org.eclipse.core.runtime.IProgressMonitor; Import org.eclipse.core.runtime.NullProgressMonitor; Public class tes {public static zero main (string [] args) {// TODO auto generated method stub IProgressMonitor progress monitor = new NullProgressMonitor (); IWorkspaceRoot root = ResourcesPlugin.getWorkspace (). GetRoot (); Ipoject project = root.jetproject ("desired projectname"); Try {Project.create (progress monitor); Project.open (progressMonitor); } Grip (CoreException E) {// TODO Auto generated blocking block e....
Read more
ios - How do I use CFArrayRef in Swift? -
July 15, 2011
I am using Objective-class in my Swift Project through a bridging header. The method signature looks like this: - Some cement (some type) some parameters; I started by getting an example of class, calling method, and storing the value: var myInstance = MyClassWithThatMethod (); Var cfArr = myInstance.someMethod (some value); Then try to get the value in the array: var valueInArrayThatIWant = CFArrayGetValueAtIndex (cfArr, 0); However, I get the error unmanaged & lt; Cfarray & gt; Not like 'CFArray' . Unmanaged & lt; Cfarray & gt; also means? I looked, but I do not need to change the array in a fast array (though it would be good). I need to be able to get value from the array. I also tried CFArray method to pass in a function: func doSomeStuffOnArray (myArray: NSArray) {} Although I get the same error when using: doSomeStuffOnArray (cfArr); // unmanaged & lt; CFArray & gt; I am using CFArray because I want to sto...
Read more
scala - Play Framework - how to bind form to a session field -
March 15, 2011
Is there any way, I can get some parameters from the header, cookies (log in userId in my case) , And then apply it in a form which I know who will deposit the ticket? SupportForm supportForm: form [supportTicket] = form (mapping ("question" -> text, "priority" -> text) (apply support ticket. (HelpText.update) What are the good practices here? What is the call to apply the request, when I can use it (and also a good practice?) Edit An issue, absolutely deceiving anyone if I were to create a hidden area with this value. It could Ript, but the issue may be re-used in any way to verify and return the form, it can not be sure how it ....
Read more
Powered by Blogger
Theme images by Michael Elkan
Unknown
Visit profile
Report Abuse
Archive
September 2015174
August 2015198
July 2015193
June 2015200
May 2015182
April 2015206
March 2015184
February 2015219
January 2015211
September 2014207
August 2014198
July 2014193
June 2014176
May 2014228
April 2014193
March 2014202
February 2014180
January 2014190
September 2013189
August 2013202
July 2013185
June 2013182
May 2013185
April 2013195
March 2013208
February 2013195
January 2013181
September 2012185
August 2012182
July 2012204
June 2012196
May 2012229
April 2012195
March 2012183
February 2012213
January 2012198
September 2011199
August 2011172
July 2011175
June 2011196
May 2011212
April 2011186
March 2011193
February 2011206
January 2011207
September 2010219
August 2010184
July 2010196
June 2010232
May 2010187
April 2010195
March 2010207
February 2010201
January 2010177
Show more
Show less