[eluser]mF4d[/eluser]
Hi guys,
I think I should ask the problem here, I've been trying to figure this out.
I made a page that will upload certain file types. It works fine in my local development but not in production.
It won't pass the do_upload() function. Nothing is displayed beyond that.
My folder structures:
Code:
public_html/gtapp/
public_html/gtapp/csystem/ <- is system folder
public_html/gtapp/v1/ <- is application folder
public_html/gtapp/media/
public_html/gtapp/uploads/
public_html/gtapp/license.txt
In config.php:
Code:
$config['base_url'] = 'http://www.mydomain.com/gtapp/
In index.php:
Code:
$application_folder = 'v1';
The uploads folder permission is 777.
I tried changing the upload_path to non existing folder, it show
'The upload path does not appear to be valid'. Means the do_upload() does work right?
Below is codeigniter codes:
Code:
$path = 'uploads';
echo 'path: '. $path .' <br>';
//-- config for uplaod --
$configUpdload['upload_path'] = $path ;
$configUpdload['allowed_types'] = 'gif|jpg|png|xls|xlsx|pdf';
$configUpdload['max_size'] = '4000'; //size in kilobytes
$configUpdload['encrypt_name'] = TRUE;
//-- load upload library --
$this->load->library('upload');
$this->upload->initialize($configUpdload);
if ($_FILES['fileref']['name']!="")
{
ini_set('display_errors', true);
error_reporting(E_ALL);
echo 'uploadAttachment<br>';
print_r($_FILES).'<br>'; //edit, added
$uploaded = $this->upload->do_upload("fileref");
echo 'uploaded: '. $uploaded . '<br>';
if ($uploaded == true)
{
echo 'uploaded data<br>';
$inputUp = $this->upload->data();
echo 'data: '. print_r($inputUp,true) . '<br>';
$uploadInput['orig_name'] = $inputUp['orig_name'];
$uploadInput['enc_name'] = $inputUp['file_name'];
$uploadInput['extension'] = $inputUp['file_ext'];
echo 'uploaded true<br>';
}else{
die($this->upload->display_errors());
}
}
I made a simple native PHP codes and it works. Below is the code:
Code:
$path = './uploads/';
$name = 'fileref';
$upload_path = 'uploads/';
$allowed_types = array("jpg", "jpeg", "gif", "png", "xls", "xlsx", "pdf");
$extension = end(explode(".", $_FILES[$name]["name"]));
$max_size = '4000';
if ($_FILES['fileref']['name']!="")
{
if ((($_FILES[$name]["type"] == "image/gif")
|| ($_FILES[$name]["type"] == "image/jpeg")
|| ($_FILES[$name]["type"] == "image/pjpeg")
|| ($_FILES[$name]["type"] == "image/png")
|| ($_FILES[$name]["type"] == "image/x-png")
|| ($_FILES[$name]["type"] == "application/excel")
|| ($_FILES[$name]["type"] == "application/vnd.ms-excel")
|| ($_FILES[$name]["type"] == "application/msexcel")
|| ($_FILES[$name]["type"] == "application/pdf")
|| ($_FILES[$name]["type"] == "application/x-download"))
&& (round($_FILES[$name]["size"]/1024,2) < $max_size )
&& in_array($extension, $allowed_types))
{
if ($_FILES[$name]["error"] > 0)
{
echo $_FILES[$name]["error"]);
}
else
{
$uploadInput['orig_name'] = $_FILES[$name]["name"];
$uploadInput['enc_name'] = sha1($_FILES[$name]["name"]);
$uploadInput['extension'] = $_FILES[$name]["type"];
$moved = move_uploaded_file($_FILES[$name]["tmp_name"], $upload_path . $uploadInput['enc_name'] . '.' . $extension);
if($moved)
echo 'success';
else
echo 'fail';
}
}
}
do_upload() does simplify things a lot, I hope could use it before turning over to the native codes.
Maybe someone have some ideas on what happen? That would be great.
*cross post
http://stackoverflow.com/questions/12337...ion-server
I apologize for cross posting.