Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6326845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:10:04+00:00 2026-05-24T17:10:04+00:00

public function save(){ $currentPage = $_SESSION[‘current_page’]; $content = $this->input->get_post(page_content); // html content $path =

  • 0
public function save(){
        $currentPage    = $_SESSION['current_page'];
        $content        = $this->input->get_post("page_content");   // html content
        $path           = $this->paths('pages');    
        $page           = $this->pages->db_get(array("id"=>$currentPage), true);

        //echo $path . $page['filename'];
        if(!is_dir($path)){
            $fileHandle = fopen($path . $page['filename'] , 'w');
            if(!fwrite($fileHandle, $content)) {
                $this->errors[] = "Error saving page";
            }
            fclose($fileHandle);
        }


echo json_encode($this->errors);
}

I receieve a html source file via ajax POST request which then i wish to write to a file as a string.
The commented line would echo */home/sajt/public_html/application/data/users/kobra@kobras.net/websites/kobra/pages/glavna.php* which exists on the server. I believe and have checked that $path, $page and $content have the correct values needed since echoing the $path . $page[‘filename’] returns a valid path to the file, but still nothing happens, that is nothing is being written.
What am i missing here?

Parent Directory permissions :

drwx------    5 sajt       sajt             4096 Aug  9 04:20 .
drwx------    3 sajt       sajt             4096 Aug  9 04:20 ..
drwxr-xr-x    2 sajt       sajt             4096 Aug  9 04:20 header
drwxr-xr-x    2 sajt       sajt             4096 Aug  9 04:20 pages
drwxr-xr-x    2 sajt       sajt             4096 Aug  9 04:20 uploads

Directory “pages” permissions:

drwxr-xr-x    2 sajt       sajt             4096 Aug  9 04:20 .
drwx------    5 sajt       sajt             4096 Aug  9 04:20 ..
-rw-r--r--    1 sajt       sajt                0 Aug  9 13:20 glavna.php
-rw-r--r--    1 sajt       sajt             1450 Aug  9 04:20 kontakt.php
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T17:10:06+00:00Added an answer on May 24, 2026 at 5:10 pm
        if(!is_dir($path)){
    

    you explicitly tell the script to skip the whole fopen/fwrite business, because as your code is written, whatever is in $path HAS to be a directory.

    Most likely you simply want

    if (is_dir($path)) {
        ^--- no !
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a class like this: class myclass { public function save($params){ // some
class News extends BaseNews { public function save(Doctrine_Connection $conn = null) { $this->setUserId($this->getAttribute('user_id')); return
public function init(){ $this->view->user = Zend_Auth::getInstance()->getIdentity(); $this->view->siteName = Zend_Registry::get('config')->site->name; $this->view->menu = $this->_helper->generateMenu(Zend_Auth::getInstance()->getIdentity()); $this->view->slogan =
public function __construct($input = null) { if (empty($input)){ return false; } and then there's
public function configure() { $this->widgetSchema['start_date'] = new sfWidgetFormInput(); $this->widgetSchema['end_date'] = new sfWidgetFormInput(); $this->validatorSchema->setPostValidator( new
Here's my RegisterController: public function saveforminformationAction(){ $request = $this->getRequest(); if($request->isPost()){ //I NEED HELP WITH
I have the following model : class Model extends BaseModel { public function save($conn
public function test(){ $data = ORM::factory('testdata')->find_all(); Table::factory() ->set_body_data($data) ->set_row_titles('id') ->set_column_titles(Table::AUTO) ->set_callback('format_row', 'row') ->render(true); $this->template->title
public function bmdToStr(bmd:BitmapData,width:int,height:int):String { var encoder:JPEGEncoder = new JPEGEncoder(); var encBytes:ByteArray = encoder.encode(bmd); return
Public Function CastToT(Of T)(ByVal GenericType(Of Object) data) As GenericType(Of T) Return DirectCast(data, GenericType(Of T))

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.