php - Uploading a PDF with CodeIgniter not working -
I am trying to upload a PDF to my website using the CodeIgniter framework. It's ok to upload a JPG or PNG, but it's not a PDF.
On my page I have two forms, but if I print the 'userfile' post from my controller, then I get the file name pdf.
This is my viewpoint code:
This is the code in my controller:
$ config [upload_path '] =' Applications / User Docs / '$ this- & gt; Input-> Post ('type document'). '/'; // is a part of the directory in 'type document' where $ config ['allowed_types'] = 'pdf' is uploaded; $ Config ['max_size'] = '0'; $ This- & gt; Load-> Library ('upload', $ config); If ($ this-> upload-> do_upload ('userfile')) {$ data ["succesmelding"] = "Upload document value document."; // upload has been done} and {$ data ["fatmelding"] = "er an e-fouut octetraden bj hat uploading van document". ;; // upload did not work} I have also added this line to the mimes.php in the config folder:
'pdf' = & gt; Edit the array ('app / pdf', 'app / x-download', 'app / unknown'), It looks like something fixed I have added these two lines of code to my controller and she worked.
$ this-> Upload-> Start ($ config); $ This- & gt; Load-> Library ('upload', $ config);
You must use the following:
Echo form_open_multipart ('subgebruiker / upload document', $ attributes); This is necessary because you are uploading the file with the file. This form adds enctype = multipart / form-data to declare this form. If the above does not work, you can change the allowed_types declaration: $ config ['allowed_types'] = '*'; // * for any mime type
Comments
Post a Comment