Welcome Guest, Not a member yet? Register   Sign In
Error uploading file pdf

(This post was last modified: 03-19-2015, 06:31 PM by gloton.)

Sorry, I do not speak English, but I have a question.
I need to upload one file only with extension pdf.

My problem is only using browser firefox, i not have problem using chrome.

My code is

public function uploadFile()
$config['upload_path'] = dirname($_SERVER["SCRIPT_FILENAME"])."/upload/";
$config['upload_url'] = base_url()."upload/";
$config['allowed_types'] = "pdf";
$config['overwrite'] = TRUE;
$config['max_size'] = "1000KB";
$config['file_name'] = "namearchivo";
$this->load->library('upload', $config);

$file_name = $_FILES['userfile']['name'];
} else {
echo "No ok";

You made some misconfiguration in upload method code,
  1. `upload_url` not any config type in upload library.
  2. `max_size` value by default in KB not need to add in value
  3. better to use more Upload library functions.
  4. you should create ./upload directory on project root folder and use `FCPATH` constant to go folder location.

see below correct sample code

PHP Code:
function uploadFile() {
   $config['upload_path'] = FCPATH "/upload/";
   $config['allowed_types'] = "pdf";
   $config['overwrite'] = TRUE;
   $config['max_size'] = "1000";
   $config['file_name'] = "namearchivo";

   if ($this->upload->do_upload()) {
       $file_data $this->upload->data();
       $file_name $file_data['file_name'];
   } else {
       echo $this->upload->display_errors('<p>''</p>');

Probably solution would be work for you  Smile
Passionate PHP Programmer & Codeigniter Developer :- Always happy to help you!

If it works with one browser and not with the other, then the problem must be the browser (or the form where you upload the files)

This is my example

url test http://localhost/CodeIgniter-2.2.1/uploads/do_upload


In google chrome all ok.. I don't understand why not it works in firefox (last version), How is it possible?.  Confused

Any idea? or some alternative?

Theme © iAndrew 2016 - Forum software by © MyBB