I've setup ActivePerl on my Windows machine and can run Perl scripts on WAMP. I am setting up Uber-Uploader and now it just telling me ERROR: Failed to find flength file.
I've set all the paths in uber.ini and in the Perl script. I guess there's something missing out there. :(
The errors you're getting are in the PHP scripts.
The name for the file that's missing is set like this:
$flength_file = $TEMP_DIR . $UPLOAD_ID . '.dir/' . $UPLOAD_ID . '.flength';
Try looking into that and please also edit your tags to include php instad of perl.
Related
I've searched all over for a solution to this and I can't find one.
I'm doing something like the following:
$data = file_get_contents('zip://../files/' . $this->_file->getHash() . '.zip#' . $stat['name']);
The specific error is:
failed to open stream: operation failed
It works on a Linux machine I use, but I'm trying to get the project running on a Windows box. I know that the path to the zip file is correct and it is readable because in the same code that the above snippet is located in, I read it using the ZipArchive class, like this:
$this->_za = new ZipArchive();
$res = $this->_za->open('../files/' . $file->getHash() . '.zip');
And that works perfectly fine.
Why can't file_get_contents read from the zip? Is there something I have to do to the files directory? I'm not very good at folders and permissions on Windows.
Edit: to be absolute sure it wasn't an issue with my code, I set up a very simple test script, with a zip file in the exact same directory:
<?php
$za = new ZipArchive();
$res = $za->open('myZip.zip');
for($i=0; $i<$za->numFiles; $i++)
{
$stat = $za->statIndex($i);
$data = file_get_contents('zip://myZip.zip#' . $stat['name']);
echo $stat['name'];
echo $data;
}
This outputs the name of each file in the zip (from the echo $stat['name'] part) but then produces the exact same error as before, i.e.,
failed to open stream: operation failed
The fix was reasonably simple. Instead of:
$data = file_get_contents('zip://myZip.zip#' . $stat['name']);
If I do:
$data = file_get_contents('zip://' . realpath('myZip.zip') . '#' . $stat['name']);
It works.
On Linux the zip wrapper needs to be compiled with PHP in order to use zip:// which appears to be the case for you.
On Windows you need to enable php_zip.dll inside of php.ini in order to use it, and may need to install a PECL extension (not sure) http://pecl.php.net/package/zip.
Not sure where you are storing the files, but this bug on PHP might be relevant to your issue https://bugs.php.net/bug.php?id=54128
I just switched a database over to a Plesk server on GoDaddy. Now, my connection script include fails with this error:
PHP Warning: include(/rev/scripts/connection.php): failed to
open stream: No such file or directory in
G:\PleskVhosts\mysite.com\httpdocs\rev\db_administration\complete_backup.php
on line 5 PHP Warning: include(): Failed opening
'/rev/scripts/connection.php' for inclusion
(include_path='.;.\includes;.\pear')
I'm not sure why it is prepending 'G:\PleskVhosts\' to the url or even if this is what is crashing it. Can anyone tell me what I am doing wrong? This code has worked for a long time, so I don't know why it needs to change with the new server.
What is strange to me is that if I run this from a browser (including the edit below), it works. But I need this to run from scheduled tasks, and there is where I get the error.
Here is the code:
<?php
$path = $_SERVER['DOCUMENT_ROOT'];
$connection = $path . '/rev/scripts/connection.php';
include ($connection);
echo "success";
?>
EDIT: Per suggestion below, I changed my code to this, which allows it run from the browser. But I still can't get it to run from scheduled tasks:
$path = !empty($_SERVER['SUBDOMAIN_DOCUMENT_ROOT']) ? $_SERVER['SUBDOMAIN_DOCUMENT_ROOT'] : $_SERVER['DOCUMENT_ROOT'];
Looking at the include path in your error message ... include(/rev/scripts/connection.php) ..., it looks like $path is an empty string. A bit of googling shows that GoDaddy doesn't always translate $_SERVER['DOCUMENT_ROOT']; correctly for some of its add-on domains and subdomains. Try replace $_SERVER['DOCUMENT_ROOT'] with $_SERVER['SUBDOMAIN_DOCUMENT_ROOT'];.
So essentially adding,
$path = !empty($_SERVER['SUBDOMAIN_DOCUMENT_ROOT']) ? $_SERVER['SUBDOMAIN_DOCUMENT_ROOT'] : $_SERVER['DOCUMENT_ROOT'];
or
$path = dirname(__FILE__); // this might or might not work.
UPDATE
$_SERVER won't work when attempting to run this from a scheduled task (presumably, via cron). Try this:
define('DOCUMENT_ROOT', substr(str_replace(pathinfo(__FILE__, PATHINFO_BASENAME), '', __FILE__), 0, -1));
It's supposed to get you the same data as $_SERVER['DOCUMENT_ROOT'] for cron jobs.
I am trying to create symlink in php with following code:
$link = (session_save_path() ? session_save_path() : sys_get_temp_dir()) . "/sess_" . $this->generateSessionId($_REQUEST['broker'], $_REQUEST['token']);
if (!file_exists($link)) $attached = symlink('sess_' . session_id(), $link);
if (!$attached) trigger_error("Failed to attach; Symlink wasn't created.".$link, E_USER_ERROR);
I am using domain name instead of localhost. I tried to run this code on
Windows 7 with Apache, and Windows 8 with IIS / IIS Express / Apache
Everytime I get same error in logs as follows:
symlink(): Could not fetch file information(error 2)
It would be great if someone can help me out in this, I already spent whole night on this thing.
Finally I found the problem.
I don't know how this code has worked for me before.
But now I checked the full path of file. It was simply session save path was different than temporary files path. So I used same session path in both links and it worked for me.
Still Thank you guys to provide me help about it.
I am using ZendFramwork1, my local sever php 5.4. and with MongoDB .I have use function Zend_Pdf to draw PDF in my project. it's run well in my local server. but when i put code to sever that have same version PHP. Everything module is okay but for function print data to pdf is errors . I got message like PDF error: Can not open 'data/reports/myfile.pdf' file for writing. . Any one can help me . what's different between my local server and real sever ?
I am looking to see your reply soon.
thank
First off, chmod 777 is a hack and shouldn't really be used. If you're using apache, you are better off chown'ing the folder to the correct user.
I am struggeling with a quite strange problem within ZendStudio. Including or requiring files inside a phar archive using the phar extensions phar:// stream wrapper will not work from within ZendStudio.
Here is what I have done.
Given the following file structure:
phar/Test.php
pharbuilder.php
usephar.php
With the following content:
phar/Test.php:
class Test {}
pharbuilder.php:
$phar = new Phar(__DIR__ . '/test.phar');
$phar->buildFromDirectory(__DIR__ . '/phar/');
usephar.php:
var_dump(file_exists('phar://' . __DIR__ . '/test.phar/Test.php'));
include('phar://' . __DIR__ . '/test.phar/Test.php');
$test = new Test();
var_dump($test);
Now, if you first run the pharbuilder.php in ZendStudio (ZS 8: right click on file, run as PHP Script) the phar file (test.phar) will be successfully created (before running it, you have to add the ini option phar.readonly=0 to the corresponding php.ini). However, running the usephar.php inside ZS, will result in an error.
bool(true)
Warning: include(): Failed opening 'phar:///somepath/test.phar/Test.php' for inclusion
So obviously, the file can be found, but it cannot be included. I can also access the content of the Test.php within the file using file_get_contents('phar://' . __DIR__ . '/test.phar/Test.php')
Also, I noticed that this will not happen, if I modify the run configuration for this script and disable the checkbox "Display debug information when running". So I assume it has something to do with the ZendDebugger, but I'm not quite sure.
When I run the same scripts from a console, everything works just fine.
I tried this with ZendStudio 8 and 10 and with all in ZS provided php versions (5.4.11, 5.3.21, 5.3.3 all in CGI and CLI).
Since I could not find anybody else with the same problem, I assume that I am doing something wrong and am open to any suggestions. Maybe some secret php.ini directive or something like this.
This issue is now fixed in Zend Studio 10.6.2.
Please mind that as mentioned above you need to modify php.ini file (located in -<studio_home>/plugins/com.zend.php.debug.debugger.win32.x86_\resources\php)
and add
phar.readonly=0