File upload() problems |
[eluser]brucebat[/eluser]
Hi all, I have been using the example here to try and get some file upload. http://ellislab.com/codeigniter/user-gui...ading.html Trying to get it to work all day and still no luck, was wondering if you guys with a spare pair of eyes could spot what I am doing wrong. View: Code: ...rest of the view The Controller: Checks if user wants to upload then calls upload function Code: //if the user selected from pulldown "Yes" The controller is echoing "Failed" so the upload is not working obviously. Any suggestions. I have been through the example above with a tooth comb trying to spot mistakes. -My folder "records" is in the root directory. -My session variable "name" is set and has a default name of "Bob" so the config folder path should be "/records/bob/" Thanks!
[eluser]LuckyFella73[/eluser]
I guess you don't get any error message? Change this code block to see what CI is complaining about: Code: if ( ! $this->upload->do_upload())
[eluser]brucebat[/eluser]
The error message it is saying is you did not specify a file to upload? I selected a file in my form? So what could this be?
[eluser]LuckyFella73[/eluser]
I can't see your whole view file so: do you have the multipart attribute in your form opening tag? Code: enctype="multipart/form-data"
[eluser]brucebat[/eluser]
Nope, I will include it now and report back to you! Okay I tried to add the multipart but still doesn't work: Here is a more descriptive account of what I am trying to achieve. Basically I want in my view for submitting data and uploading a file and that this would all be processed through the one form. 1 -User enters data -User selects an electronic copy of the data a pdf or excel file 2 +Data in form gets sent to database +File gets uploaded to site with an id that matches the record in the database Here is the structure of my view Code: echo form_open('submit/validateform'); This might be an unorthodox way to do it, but I want to achieve it all in the one form/view so its easier for my users rather than do each task seperately.
[eluser]brucebat[/eluser]
Ok so I tried it with many file and it is still giving me no file selected. I was wondering could this be to do with file permissions? Also how do I set my file permission on localhost computer? Thanks
[eluser]LuckyFella73[/eluser]
I don't know if that's the problem but you can't have this: Code: echo form_upload('userfile', set_value('userfile')); Should look like: Code: echo form_upload('userfile'); You can't set the value of a input "type file". When the upload fails the user has to select the file again. Check the parsed source-code in your browser and be sure that the name of the input/file is "userfile". I don't think it's a permission problem otherwise you should get an error message like "the folder ... seems not to be writable". Just in this sense ![]() On Windows you don't have to set a permission, on a Linux server I guess you need 777 (CI Userguide say so) I would set a "allowed_types" value btw. You have to set at least one type or use a wildcard: Code: $config['allowed_types'] = '*'
[eluser]brucebat[/eluser]
Okay I have changed my code aroun a bit so what I have is a seperate form for uploading a file. However now I am getting an error message Quote:The upload path does not appear to be valid. This is the code: Code: function upload_record() My records folder is in the root directory This is my baseurl http://localhost/midas/ File path C:\xampp\htdocs\midas Screenshot: http://i.imgur.com/9iDhL.jpg
[eluser]Ivar89[/eluser]
Try this: Code: $config['upload_path'] = './records/';
[eluser]brucebat[/eluser]
It works!! So what does the "." do is it similar to ".." when you do file hrefs in HTML? |
Welcome Guest, Not a member yet? Register Sign In |