Message: move_uploaded_file(): failed to open stream: Permission denied in codeigniter - codeigniter

my project ran well in localhost using xampp but in remote server I've got an error when Im trying to upload or update an image,..
warning:
Message: move_uploaded_file(images/1458100947_2.jpg):
failed to open stream: Permission denied
here is the code were the errors located.
$imagename = $this->person->view($this->input->post('id'))->image;
if(file_exists("images/$imagename")) unlink("images/".$imagename);
$fileName = time(). '_' .$_FILES["image"]["name"];
move_uploaded_file($_FILES["image"]["tmp_name"],$output_dir.$fileName); //this line
$targetPath = 'images/' . $fileName;
$config_resize['image_library'] = 'gd2';
$config_resize['create_thumb'] = FALSE;
$config_resize['maintain_ratio'] = TRUE;
// $config_resize['master_dim'] = 'height';
$config_resize['quality'] = "80%";
$config_resize['source_image'] = $targetPath;
$config_resize['height'] = 600;
$config_resize['width'] = 1024;
// $config_resize['thumb_marker'] = '';
$config_resize['new_image'] = 'images/' . $fileName;
$this->image_lib->initialize($config_resize);
$this->image_lib->resize();
$uploaded = TRUE;
I am trying to google on how to set the permission to 777 in codeigniter but no luck.. here is my project link http://mysports.orgfree.com. use this admin account.
username: mak password: mak
to login and click the edit button then upload some image.. the error will show after that.. thank you...

Hello you can give 2 way permission
1) directly give folder permission using this way
chmod("folder name with path", 755);
2)directly give file permission using this way and use this code after move_uploaded_file function
chmod("file name with path", 644);

I was able to fix my permission issue by using SmartFTP to upload the files, because it provides an easy way to set the permission. This resolved my question and my code works now.

Related

unlink(assets/images/profile/1649308242.png): No such file or directory

error after deploy my laravel app to server
my code works fine on my loacal machine but after upload it to the server i got this error
if($this->newimage)
{
if($this->image)
{
unlink('assets/images/profile/'.$this->image);
}
$imageName = Carbon::now()->timestamp . '.' . $this->newimage->extension();
$this->newimage->storeAs('profile',$imageName);
$user->profile->image = $imageName;
}
The address of a file should be an absolute path. I don't know where is your assets directory but in the case of being in your Laravel app root, this would be the solution:
unlink(base_path('assets/images/profile/'.$this->image));
you can set your storage directory instead of public
$storePath = storage_path('app/public/'.$this->image);
if (file_exists($storePath)) {
Storage::disk('public')->delete($this->image);
}
use the helper asset('path/to/file')
e.g.
if this is your image path public/assets/images/profile/1649308242.png.
unlink(asset('assets/images/profile').'/'.$this->image);

Error index.php not writeable Administrator index.php not writeable In opencart

i've got problem when i install vqmod in opencart the error say
index.php not writeable
Administrator index.php not writeable
i have no index.php file in my root opencart ,
Admin/index.php
<?php
// Version
define('VERSION', '2.3.0.2');
// Configuration
if (is_file('config.php')) {
require_once('config.php');
}
// Install
if (!defined('DIR_APPLICATION')) {
header('Location: ../install/index.php');
exit;
}
// Startup
require_once(DIR_SYSTEM . 'startup.php');
start('admin');
vqmod/install/index.php
// CHANGE THIS IF YOU EDIT YOUR ADMIN FOLDER NAME
$admin = 'admin';
// Counters
$changes = 0;
$writes = 0;
// Load class required for installation
require('ugrsr.class.php');
// Get directory two above installation directory
$opencart_path = realpath(dirname(__FILE__) . '/../../') . '/';
// Verify path is correct
if(!$opencart_path) die('COULD NOT DETERMINE CORRECT FILE PATH');
$write_errors = array();
if(!is_writeable($opencart_path . 'index.php')) {
$write_errors[] = 'index.php not writeable';
}
if(!is_writeable($opencart_path . $admin . '/index.php')) {
$write_errors[] = 'Administrator index.php not writeable';
}
if(!empty($write_errors)) {
die(implode('<br />', $write_errors));
}
// Create new UGRSR class
$u = new UGRSR($opencart_path);
// remove the # before this to enable debugging info
#$u->debug = true;
// Set file searching to off
$u->file_search = false;
// Attempt upgrade if necessary. Otherwise just continue with normal install
$u->addFile('index.php');
$u->addFile($admin . '/index.php');
$u->addPattern('~\$vqmod->~', 'VQMod::');
$u->addPattern('~\$vqmod = new VQMod\(\);~', 'VQMod::bootup();');
$result = $u->run();
if($result['writes'] > 0) {
if(file_exists('../mods.cache')) {
unlink('../mods.cache');
}
die('UPGRADE COMPLETE');
}
$u->clearPatterns();
$u->resetFileList();
// Add catalog index files to files to include
$u->addFile('index.php');
// Pattern to add vqmod include
$u->addPattern('~// Startup~', '// VirtualQMOD
require_once(\'./vqmod/vqmod.php\');
VQMod::bootup();
// VQMODDED Startup');
$result = $u->run();
$writes += $result['writes'];
$changes += $result['changes'];
$u->clearPatterns();
$u->resetFileList();
// Add Admin index file
$u->addFile($admin . '/index.php');
// Pattern to add vqmod include
$u->addPattern('~// Startup~', '//VirtualQMOD
require_once(\'../vqmod/vqmod.php\');
VQMod::bootup();
// VQMODDED Startup');
$result = $u->run();
$writes += $result['writes'];
$changes += $result['changes'];
$u->addFile('index.php');
// Pattern to run required files through vqmod
$u->addPattern('/require_once\(DIR_SYSTEM \. \'([^\']+)\'\);/', 'require_once(VQMod::modCheck(DIR_SYSTEM . \'$1\'));');
// Get number of changes during run
$result = $u->run();
$writes += $result['writes'];
$changes += $result['changes'];
// output result to user
if(!$changes) die('VQMOD ALREADY INSTALLED!');
if($writes != 4) die('ONE OR MORE FILES COULD NOT BE WRITTEN');
die('VQMOD HAS BEEN INSTALLED ON YOUR SYSTEM!');
you need to do two things
1)open vqmod/install/index.php
find the following code
$admin = 'admin';
change its value to your admin folder name that you have changed to
$admin = 'youradminfoldername';
2)open vqmod/pathReplaces.php
find the following code (if there is no,add it)
$replaces[] = array('~^admin\b~', 'xxxxx');
change xxxxx to your current admin folder name.
after you have these two things,even if it still show such infomation,
you should be ok to install extension.
I have tested this method ,it works for me.
another solution I guess maybe is to delete vqmod folder and reupload vqmod-opencart-2.6.1,and then only need to modify vqmod/pathReplaces.php,it should works
It probably means that you've deleted the file. You might have to reinstall the Opencart or upload the file from default opencart source files.
Open cPanel File Manager Set permission to 777 for the file

Getting Error in Library inclusion in Codeigniter controller

When i run my aaplication in external server i get eror ,
Message: Login::include_once(application/third_party/mpdf/mpdf.php) [function.Login-include-once]: failed to open stream: No such file or directory.
The same application was running perfect in local server. Can anyone please suggest what could be wrong with it. My controller function ,
function pdfapp() //for test run individually
{
$this->load->model('Registration_model');
$appno='4/SCSELB/2013/KL01';
$data['table'] = $this->Registration_model->getall_app($appno);
$data['own_land'] = $this->Registration_model->get_ownland($appno);
$data['loan_data'] = $this->Registration_model->getloan_data($appno);
$apppdf='4_SCSELB_2013_KL01';
$data['apppdf']=$apppdf;
$pdfFilePath = FCPATH."reports/application/$apppdf.pdf";
if (file_exists($pdfFilePath) == FALSE)
{
ini_set('memory_limit','32M');
$html = $this->load->view('pdf_report2', $data, true);
include_once APPPATH.'third_party/mpdf/mpdf.php';
$mpdf=new mPDF('c');
$mpdf->SetFooter(' copyright# KSDC'.'|{PAGENO}|'.'Applied on '.date('d-M-Y H.i.s'));
$mpdf->WriteHTML($html);
$mpdf->Output($pdfFilePath, 'F');
}
$this->load->view('pdf_report2',$data);
}
The error you're getting is of a file not existing, Did you you debug this line ?
APPPATH.'third_party/mpdf/mpdf.php'; ?
what path do you get if you var_dump it?

Your credentials do not allow access to this resource [code] => 220

I am using twitter login for magento i configure everything but when get the user informations the give the following error.Your credentials do not allow access to this resource [code] => 220. if some body face this type of problem then help me and thanks in advance.
my code is
$CONSUMER_KEY='xxxxxxxxxxxxxxxxx';
$CONSUMER_SECRET='xxxxxxxxxxxxxxxxxxxxxx';
$OAUTH_CALLBACK='http://demo004.fmeaddons.com';
session_start();
$twitteroauth = new TwitterOAuth($CONSUMER_KEY, $CONSUMER_SECRET);
$request_token = $twitteroauth->getRequestToken($OAUTH_CALLBACK);
$_SESSION['oauth_token'] = $request_token['oauth_token'];
$_SESSION['oauth_token_secret'] = $request_token['oauth_token_secret'];
if($twitteroauth->http_code==200){
$url = $twitteroauth->getAuthorizeURL($request_token['oauth_token']);
echo $url;
$twitteroauth = new TwitterOAuth($CONSUMER_KEY, $CONSUMER_SECRET, $_SESSION['oauth_token'], $_SESSION['oauth_token_secret']);
$access_token = $twitteroauth->getAccessToken($_GET['oauth_verifier']); $_SESSION['access_token'] = $access_token;
$user_info = $twitteroauth->get('account/verify_credentials');
print_r($user_info);
} else {
die('Something wrong happened.');
}
Make sure your keys were created with the correct permissions. You can check this in the "Keys and tokens" section of your Twitter developer dashboard:

Fatal error: require_once() : Failed opening required error with codeigniter

I have an application that works on my local, development server, but when uploaded to the remote, production server I see the following error:
Fatal error: require_once() [function.require]: Failed opening required '/home/madhab/public_html/system/database/drivers/mysql/mysql_driver.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/madhab/public_html/system/database/DB.php on line 140
What's the matter? How can I resolve it?
//my database configuration as
$active_group = 'server';
$active_record = TRUE;
$db['server']['hostname'] = 'madhab-acharya.com.np';
$db['server']['username'] = '***********';
$db['server']['password'] = '***********';
$db['server']['database'] = '***********';
$db['server']['dbdriver'] = 'mysql';
$db['server']['dbprefix'] = '';
$db['server']['pconnect'] = TRUE;
$db['server']['db_debug'] = TRUE;
$db['server']['cache_on'] = FALSE;
$db['server']['cachedir'] = '';
$db['server']['char_set'] = 'utf8';
$db['server']['dbcollat'] = 'utf8_general_ci';
$db['server']['swap_pre'] = '';
$db['server']['autoinit'] = TRUE;
$db['server']['stricton'] = FALSE;
//and my index.php file setting is
$system_path = 'system';
$application_folder = 'application';
$assets_folder = 'assets';
while my application, system, index.php resides on public_html folder in remote server
somebody please help me thro this
Problem is with mysql host.
normally it is like madhab-acharya.mysqlserver.com.np. I think you have give your web site name.
Please check your sql hostiname with your web service provide or you can find it in phpadmin panel.
If this is correct ensure that every file is uploaded correctly. Sometimes I had to do second time when I put site in productions.

Resources