![](/img/trans.png)
[英]Read the lines of several txt files that are inside a folder and create a single text file containing all lines of text
[英]Create txt files if not exists php, in a different folder
因此,基本上我将php脚本保存在一个文件夹中,如果该文件尚不存在,我想在/ cache中创建一个txt文件。 如果存在,则应中止并继续执行脚本的其余部分。
$(document).ready(function() {
var feed = $("#instagramFeed .wrap");
$.ajax({
type: "POST",
url: "<?= path("instagram_feed.php"); ?>",
data: { feed_url: "http://iconosquare.com/feed/<?= $butikInstagram ?>", instagram_url: "http://instagram.com/<?= $butikInstagram ?>", cache_file: "<?= $butikInstagram ?>.txt" },
success: function(data) {
console.log("SUCCESS");
feed.html(data).find("img").show();
}
});
});
在我的instagram_feed.php中,我现在尝试使用:
$cache_file = $_POST['cache_file'];
$fh = fopen("cache/"+$cache_file, 'w') or die("fail");
它返回失败...我在高速缓存文件夹上也有chmod 777。
我究竟做错了什么?
您正在尝试使用+
cache/"+$cache_file
。
旁注: +
是JS / C ++的连接方法。
它必须是一个点。 另外,请确保已设置短标签。
您还将需要chmod您的文件。
在注释中,您说过使用chmod("cache/".$cache_file, 777);
需要读取为chmod("cache/".$cache_file, 0777);
OP: 好的,我的错,没有将参数传递给函数!
将错误报告添加到文件顶部,这将有助于发现错误。
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
// rest of your code
旁注:错误报告仅应在登台进行,而不应在生产过程中进行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.