相关疑难解决方法(0)

使用PHP解析URL中的相对路径

示例1:domain.com/dir_1/dir_2/dir_3/./../../../
应在浏览器中自然解析为=domain.com/

例2:domain.com/dir_1/dir_2/dir_3/./../../../test/././../new_dir/
应该解决domain.com/new_dir/

例3:domain.com/dir_1/dir_2/dir_3/./../../../test/dir4/../final
应该解决domain.com/test/final

问题是......我怎么能遍历字符串才能做到这一点?我觉得for()循环在这一点上会感到困惑.

使用PHP
PHP将相对路径转换为绝对URL
:如何解析相对URL

在这种情况下对我不起作用..我不应该需要一个参考点(基础),因为目标是清理我已经拥有的东西.

php url relative-path resolve

4
推荐指数
1
解决办法
2292
查看次数

file_get_contents()无法打开流:没有这样的文件或目录

我正在写一些PHP脚本来更新我的网站上的代码.为了做到这一点,我写了以下几行来检查更新版本,并从我用于分发我的更新的地方带来名称然后创建该名称的链接.我做过这样的事情.

$filename = "http://www.hf-live.com/codeupdate/Get_Files_Name.php";
$contents = file_get_contents($filename);
echo $contents;
Run Code Online (Sandbox Code Playgroud)

我收到了这个错误

无法打开流:没有这样的文件或目录.

即使该文件存在仍然我得到相同的错误.我转过身allow_url_fopenon.上面的代码是从我的本地主机,但不是从服务器.我必须更新一个主要的错误修复,我被卡住..请有人帮助我很快..

php

4
推荐指数
1
解决办法
2万
查看次数

无法打开流没有这样的文件或目录.PHP

我有一个Profile.php包含Profile_Control.phpprofile_control包含的文件Profile_Model.php.在这里,每件事情都很好.

我有另一个脚本命名,Upload.php从哪个数据上传.这个Upload.php还包括Profile_Control.php并且如你所知Profile_Control包含Profile_Model.php.现在我不知道它为什么会出现这样的错误.当Profile.php加载它工作正常但是当我上传数据时它说

Warning: include(../Model/Profile_Model.php) [function.include]: failed to open stream: No such file or directory in C:\wamp\www\php\gagster\Control\Profile_Control.php on line 4
Run Code Online (Sandbox Code Playgroud)

在Upload.php中:

include_once("../../Control/Profile_Control.php");
Run Code Online (Sandbox Code Playgroud)

在Profile.php中:

include_once("../Control/Profile_Control.php");
Run Code Online (Sandbox Code Playgroud)

在Profile_Control.php中:

include_once("../Model/Profile_Model.php");
Run Code Online (Sandbox Code Playgroud)

文件结构:

 +-Control/
 |  |    
 |  +---- Profile_Control.php
 |
 +-Model/
 |  |
 |  +---- Profile_Model.php
 |
 +-Other/
    |
    +-- Upload/
           |
           +---- Upload.php
Run Code Online (Sandbox Code Playgroud)

php php-include

3
推荐指数
1
解决办法
1万
查看次数

警告:复制(..):无法打开流:中没有这样的文件或目录

我对 PHP 还很陌生,正在尝试创建一个简单的 PHP 文件上传系统。

我遵循了(http://www.phpeasystep.com/phptu/2.html)的教程。我只更改了$HTTP_POST_FILES,因为它给了我错误,并且从我读到的内容来看,它在 PHP 中很旧。

我收到的错误消息较少,但在copy()函数中出现错误,并显示以下错误消息:

Warning: copy(Task2/uploads/anonymous.jpg): failed to open stream: No such file or directory in C:\xampp\htdocs\Task2\upload.php on line 13

Warning: copy(Task2/uploads/DSCF4639.JPG): failed to open stream: No such file or directory in C:\xampp\htdocs\Task2\upload.php on line 14

Warning: copy(Task2/uploads/jien maroon.jpg): failed to open stream: No such file or directory in C:\xampp\htdocs\Task2\upload.php on line 15
Run Code Online (Sandbox Code Playgroud)

我认为这是权限问题(Windows 7 中的读/写权限),但从谷歌快速搜索来看,XAMPP 似乎默认设置为处理 Win 7 上的权限。

这是代码:

<?php

//set where you want to store files …
Run Code Online (Sandbox Code Playgroud)

php upload file-upload copy stream

3
推荐指数
1
解决办法
4万
查看次数

在尝试执行php文件时,PHP无法打开Stream没有这样的文件或目录

嗨伙计们,我一直得到:

failed to open Stream: No such file or directory " Path " on line 2

当我尝试从命令行运行此php文件时.

require_once 'modules/Reports/ScheduledReports.php'
VTScheduledReport::runScheduledReports($adb);
Run Code Online (Sandbox Code Playgroud)

我已经检查过文件是否存在,并且有一个名为class VTScheduledReportin ScheduledReports.php的类和函数runScheduledReports.在那儿.该函数如下所示:

public static function runScheduledReports($adb) {
    require_once 'modules/com_vtiger_workflow/VTWorkflowUtils.php';
    $util = new VTWorkflowUtils();
    $adminUser = $util->adminUser();

    global $currentModule, $current_language;
    if(empty($currentModule)) $currentModule = 'Reports';
    if(empty($current_language)) $current_language = 'en_us';

    $scheduledReports = self::getScheduledReports($adb, $adminUser);
    foreach($scheduledReports as $scheduledReport) {
        $scheduledReport->sendEmail();
        $scheduledReport->updateNextTriggerTime();
    }
    $util->revertUser();
}
Run Code Online (Sandbox Code Playgroud)

任何人都知道为什么这不会运行?

php command-line

3
推荐指数
1
解决办法
2043
查看次数

警告:require_once(Zend/Application.php):无法打开流:/ var/w中没有这样的文件或目录

我的索引文件就是这个

<?php
ini_set( "short_open_tag", 1 );
ini_set( "display_errors", 1 );
// Define path to application directory

defined('APPLICATION_PATH')
    || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
// Define application environment
defined('APPLICATION_ENV')
    || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));

// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
    realpath(APPLICATION_PATH . '/../library'),
    get_include_path(),
)));
/** Zend_Application */
require_once 'Zend/Application.php';

// Create application, bootstrap, and run
$application = new Zend_Application(
    APPLICATION_ENV,
    APPLICATION_PATH . '/configs/application.ini'
);

// Let 'er rip
$application->bootstrap()->run();
Run Code Online (Sandbox Code Playgroud)

当我跑那个

警告:require_once(Zend/Application.php):无法打开流:第18行/var/www/Giftercity_backup/index.php中没有此类文件或目录致命错误:require_once():无法打开所需的'Zend/Application.第18行的/var/www/Giftercity_backup/index.php中的php'(include_path =':.:/ usr/share/php:/ usr/share/pear')

zend-framework

3
推荐指数
1
解决办法
2万
查看次数

无法包含文件并且"无法打开流:没有此类文件或目录"警告消息

包含文件时出现以下错误.

 Warning:  require(home2/myusername/public_html/inc/config.php) 
 [function.require]: failed to open stream: No such file or directory in 
 /home2/myusername/public_html/inc/bootstrap.php on line 32

 Fatal error:  require() [function.require]: Failed opening required 
 'home2/myusername/public_html/inc/config.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in 
 /home2/myusername/public_html/inc/bootstrap.php on line 32
Run Code Online (Sandbox Code Playgroud)

它在我在Windows PC上运行的localhost中工作正常.但是当我在我的共享托管服务器CentOS上传文件时,我收到了这个错误.

home2/myusername/public_html/index.php包括/inc/bootstrap.php然后试图包括/inc/config.php.该文件config.php确实存在于服务器上.home2/myusername/public_html/由函数返回getcwd().

下面是bootstrap.php中发出错误的前几行代码.

define('APP_DIR', 'app');   

if( !defined('APP_ROOT') ){
    $APP_ROOT = trim(getcwd(), '/').'/';
    if(isset($_GET['bootstrap'])) $APP_ROOT .= APP_DIR . '/';
    define('APP_ROOT', $APP_ROOT);
}

if( !defined('ROOT') ){
    $ROOT = str_replace(APP_DIR, '', trim(APP_ROOT, '/'));
    if( strrpos($ROOT, '/') != strlen($ROOT)-1 ) …
Run Code Online (Sandbox Code Playgroud)

php centos file include

3
推荐指数
1
解决办法
4万
查看次数

致命错误:未在sdk Paypal中找到“ Paypal \ Api \ Payer”类

我用作曲家安装了PayPal SDK,但我的php文件CHECKOUT.php出现错误:

致命错误:在第23行的C:\ xampp \ htdocs \ pagos \ checkout.php中找不到类“ Paypal \ Api \ Payer”

checkout.php:

<?php
require ("start.php");

use Paypal\Api\Payer;
use Paypal\Api\Item;

$payer = new Payer();
$payer->setPaymentMethod("paypal");

$item = new Item();
$item->setName($descripcion)
    ->setCurrency('MXN')
    ->setQuantity(1)
    ->setPrice($precio);
$itemList = new ItemList();
$itemList->setItems([$item]);
Run Code Online (Sandbox Code Playgroud)

start.php

<?php
// 1. Autoload the SDK Package. This will include all the files and classes to your autoloader
// Used for composer based installation
require __DIR__  . '/vendor/autoload.php';
// Use below for direct download installation
// require __DIR__ …
Run Code Online (Sandbox Code Playgroud)

php paypal paypal-sandbox paypal-rest-sdk

3
推荐指数
1
解决办法
1892
查看次数

fopen:无法打开流:Mac上的PHP权限被拒绝

我写了这段代码:

if (file_exists("testfile.rtf")) echo "file exists.";
else echo "file doesn't exist.";

$fh = fopen("testfile.rtf", 'w') or die("impossible to open the file");

$text = <<< _END
Hi buddies, 
I write for the first time
in a PHP file!
_END;

fwrite($fh, $text) or die("Impossible to write in the file");
fclose($fh);
echo ("writing in the file 'testfile.rtf' succeed.");
Run Code Online (Sandbox Code Playgroud)

但是,当我运行它时,它说:

fopen(testfile.rtf):无法打开流:第64行/Applications/XAMPP/xamppfiles/htdocs/test/test1.php中的权限被拒绝无法打开文件

我在我的MAC上使用XAMPP在本地服务器上工作.

我找到了几个主题,其中一些人有同样的问题,并使用一个名为"chmod 777"的东西解决了它,但我不知道这意味着什么,在哪里写这个,等等.

php macos

3
推荐指数
1
解决办法
9275
查看次数

PHP - fopen():无法打开流:mac上的权限被拒绝?

我无法让它工作并在同一目录中创建一个简单的文件.

我使用的是Mac,文本编辑器是Sublime Text,php版本是5.5.30.

这是我正在执行的代码:

<?php  
  $file = fopen( 'data/data.txt' , 'w' );
  if( $file ) {
    echo 'The file is open';
    fclose( $file );
  }else{
    echo 'The file could not be open.';
  }
?>
Run Code Online (Sandbox Code Playgroud)

这是浏览器中生成的错误:

警告:fopen(data/data.txt):无法打开流:第17行/Library/WebServer/Documents/php_class/class_examples/open_and_close.php中的权限被拒绝

我在网上搜索了错误的答案,这是我解决问题的解决方案:

打开终端,转到脚本所在的目录,然后输入以下命令

sudo chmod 777 open_and_close.php
Run Code Online (Sandbox Code Playgroud)

现在我做了所有这些,我仍然得到同样的错误.关于我做错的任何建议?

谢谢.

php fopen

2
推荐指数
1
解决办法
3万
查看次数