Welcome Guest, Not a member yet? Register   Sign In
[HELP] Upload File gives Blank Page in Production Server.
#1

[eluser]vipersnake[/eluser]
Hello guys Ive been at this for over 2 days and its driving me crazy,

i am running the code locally and everything works, i can upload files like there is no tomorrow but then i uploaded the code and everything works except the upload functionality, you try to upload a picture for example and it will post back an empty page.. blank no code or anything just blank... of course i thought it might be that the production uploads folder doesn't have the write permission so i went to the server and changed its permission to 777 but I'm still getting the error... then i thought maybe is the path.. changed the path(./images/uploads/) to realpath(dirname(__FILE__)) and that gave me the path to the controller folder which i didn't need then tried just dirname(__FILE__) with the same results finally i tried realpath($_SERVER["DOCUMENT_ROOT"]).'/images/uploads/' and that one gave me the real full path to the folder but still blank page...

checked the logs and nothing...
here is my folder structure

+application
+images
-uploads
-css
-js
index.php

what is wrong?? thank you all in advance!
#2

[eluser]Mr. Pickle[/eluser]
Did you try changing the environment to development in de main index.php.
Maybe nothing is outputted as the environment is set to production.

Also, do you in any way echo an error if one occurred during the upload process? Like:
Code:
if ( ! $this->upload->do_upload())
{
    echo $this->upload->display_errors();
    exit();
}
#3

[eluser]vipersnake[/eluser]
yes, but still nothing... blank page, here is my code

Controller:

if (!empty($_FILES['userfile']['name']))
{
$config['upload_path'] =realpath($_SERVER["DOCUMENT_ROOT"]).'/images/uploads';
$config['file_name'] = str_replace(array("{","}"),"",com_create_guid());
$config['allowed_types'] = 'gif|jpg|png';
$config['remove_spaces'] = true;
$config['max_size'] = '1000';
$config['max_width'] = '400';
$config['max_height'] = '400';

$this->load->library('upload', $config);


if ($this->upload->do_upload())
{
$fData = $this->upload->data();
}
else
{
echo $this->upload->display_errors();
}
}

View:
echo '<li>';
echo '&lt;input type="file" name="userfile" size="20" /&gt;';
echo '</li>';
#4

[eluser]Mr. Pickle[/eluser]
Try this to see if it get's through certain parts

Code:
if (!empty($_FILES['userfile']['name']))
{
  $config[‘upload_path’] =realpath($_SERVER[“DOCUMENT_ROOT”]).’/images/uploads’;
  $config[‘file_name’] = str_replace(array(”{”,”}”),”“,com_create_guid());
  $config[‘allowed_types’] = ‘gif|jpg|png’;
  $config[‘remove_spaces’] = true;
  $config[‘max_size’] = ‘1000’;
  $config[‘max_width’]  = ‘400’;
  $config[‘max_height’]  = ‘400’;
  
  echo 'before loading library<br />';

  $this->load->library(‘upload’, $config);

  echo 'after loading library<br />';

  if ($this->upload->do_upload())
  {
    echo 'do upload succeeded<br />';
    $fData = $this->upload->data();
    echo 'fdata set<br />';
    exit();
  }
  else
  {
    echo 'oops, do upload failed!<br />';
    echo $this->upload->display_errors();
    echo 'after error display<br />';
    exit();
  }
}
#5

[eluser]vipersnake[/eluser]
[quote author="Mr. Pickle" date="1350328700"]Try this to see if it get's through certain parts

Code:
if (!empty($_FILES['userfile']['name']))
{
  $config[‘upload_path’] =realpath($_SERVER[“DOCUMENT_ROOT”]).’/images/uploads’;
  $config[‘file_name’] = str_replace(array(”{”,”}”),”“,com_create_guid());
  $config[‘allowed_types’] = ‘gif|jpg|png’;
  $config[‘remove_spaces’] = true;
  $config[‘max_size’] = ‘1000’;
  $config[‘max_width’]  = ‘400’;
  $config[‘max_height’]  = ‘400’;
  
  echo 'before loading library<br />';

  $this->load->library(‘upload’, $config);

  echo 'after loading library<br />';

  if ($this->upload->do_upload())
  {
    echo 'do upload succeeded<br />';
    $fData = $this->upload->data();
    echo 'fdata set<br />';
    exit();
  }
  else
  {
    echo 'oops, do upload failed!<br />';
    echo $this->upload->display_errors();
    echo 'after error display<br />';
    exit();
  }
}
[/quote]
same thing, blank page, i inserted an echo just before if (!empty($_FILES['userfile']['name'])), and now the blank page shows the echo just before but nothing else...
#6

[eluser]Mr. Pickle[/eluser]
Add a else statement to the if (!empty($_FILES['userfile']['name']))
So:

Code:
if (!empty($_FILES['userfile']['name']))
{
    // what was already there
}
else
{
    echo 'userfile seems empty!';
}

Gives at least the info if it gets into the if, if there was no else before it can explain why page stays empty without errors or echoes.




Theme © iAndrew 2016 - Forum software by © MyBB