尝试使用fopen()将文件写入其他目录 [英] Trying to write a file to a different directory using fopen()

查看:253
本文介绍了尝试使用fopen()将文件写入其他目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将文件从一个目录写入另一个目录.例如, http://www.xxxxxxx.com/admin/upload.php http://www.xxxxxxx.com/posts/filename.php

I'm trying to write a file from one directory to another. For example, http://www.xxxxxxx.com/admin/upload.php to http://www.xxxxxxx.com/posts/filename.php

我读到我无法使用HTTP路径写入文件,如何使用本地路径?

I've read that I cannot write a file by using the HTTP path, how do I use a local path?

$ourFileName = "http://www.xxxxxxxx.com/articles/".$thefile.".php";
$ourFileHandle = fopen($ourFileName, 'w') or die("can't open file");

推荐答案

您应在文件系统上使用文件的绝对或相对路径.

You should use the absolute or relative path to the file on the file system.

<?php

$absolute_path = '/full/path/to/filename.php';
$relative_path = '../posts/filename.php';

// use one of $absolute_path or $relative_path in fopen()

?>

这篇关于尝试使用fopen()将文件写入其他目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆