Problem with wordpress file system API on some hosts (1 post)

  1. Satish Gandham
    Posted 4 years ago #

    I'm using WordPress file system api to write the CSS file.
    On some hosts automatic plugin and theme updates work without problem, but my script won't work.
    Looks like its unable to access the temporary file.

    How do i fix this?

    code from wp-admin/incudes/class-wp-filesystem-ftpext.php

    function put_contents($file, $contents, $mode = false ) {
    		$tempfile = wp_tempnam($file);
    		$temp = fopen($tempfile, 'w+');
    		if ( ! $temp )
    			return false;
    /* Added these three lines, and removed @ before ftp_fput*/
    		fwrite($temp, $contents);
    		fseek($temp, 0); //Skip back to the start of the file being written to
    		$type = $this->is_binary($contents) ? FTP_BINARY : FTP_ASCII;
    		$ret = ftp_fput($this->link, $file, $temp, $type);
    		$this->chmod($file, $mode);
    		return $ret;

    /* this is the result*./

    string(92) "/home/**/domains/*******/public_html/wp-content/uploads/swift-magic/custom-styles.css"
    string(22) "/tmp/custom-styles.tmp"
    resource(351) of type (stream)
    Warning: ftp_fput() [function.ftp-fput]: /home/***/domains/*******/public_html/wp-content/uploads/swift-magic/custom-styles.css: No such file or directory in /home/**/domains/*****/public_html/wp-admin/includes/class-wp-filesystem-ftpext.php on line 130

    I created the file and made it writable, but I'm still getting the same error.

Topic Closed

This topic has been closed to new replies.

About this Topic

  • RSS feed for this topic
  • Started 4 years ago by Satish Gandham
  • This topic is not resolved
  • WordPress version: 3.3.1