我在Laravel 5中的这个目录中存储了一个.csv文件:
/storage/app/data.csv
在这个函数里面我试着读取这个文件的内容并从中提取几个列,比如名称和城市到数组,示例代码:
use Illuminate\Support\Facades\Storage;
public function get_data() {
$file_n = Storage::url('data.csv');
$file = fopen($file_n, "r");
$all_data = array();
while ( ($data = fgetcsv($file, 200, ",")) !==FALSE {
$name = $data[0];
$city = $data[1];
$all_data = $name. " ".$city;
array_push($array, $all_data);
}
fclose($file);
}
Run Code Online (Sandbox Code Playgroud)
我在Controller中收到ErrorException:
fopen(/storage/data.csv): failed to open stream: No such file or directory
Run Code Online (Sandbox Code Playgroud)
但文件就在那里.有没有更好的方法来做到这一点?
谢谢你的期待!
我仍然无法使这个代码工作,我试图使用"onClick"交换图像一旦点击,在新窗口中打开这个新页面,打印这个新打开的窗口并关闭它.它会在新窗口中打开新页面,但它会打印一个空白页面并且无法关闭它,似乎没有以某种方式设置焦点.任何人都可以帮助我吗?谢谢!
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Print it</title>
<!--style type="text/css" media="print"> .noprint {visibility: hidden;} </style-->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
$(".img-swap").live('click', function() {
if ($(this).attr("class") == "img-swap") {
this.src = this.src.replace("_off","_on");
} else {
this.src = this.src.replace("_on","_off");
}
$(this).toggleClass("on");
});
});
</script>
<script type="text/javascript">
// <!--
Popup = {
init : function () {
$('a.action_print').bind('click', Popup.printIt);
},
printIt : function () {
var win = window.open('doc1.html','Printed','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=350,height=250');
if (win) {
win.document.close();
win.focus();
win.print();
}
return false;
}
} …Run Code Online (Sandbox Code Playgroud) 我有一个网页,使用下面的链接,现在每次我访问该页面时都会出现一个对话框,询问用户名和密码进行身份验证.我之前从来没有过这样的事情.这是一个新的错误或新的东西,以前有人看过这个,有没有办法解决这个问题?
http://jqueryrotate.googlecode.com/svn/trunk/jQueryRotate.js
谢谢!
我试图在这种情况下删除图表的“传奇”文本“得分列表”左侧的小矩形框。我在文档中找不到任何显示方法的内容。是的,我发现了如何完全删除“传奇”,但这会导致条形图在图表设计中变得过高。这是我有一个示例代码:
<!DOCTYPE html>
<html>
<head>
<title>ChartJS - BarGraph</title>
<style type="text/css">
#chart-container {
width: 300px;
height: 150px;
}
</style>
<!-- javascript -->
<script type="text/javascript" src="jquery-1.11.min.js"></script>
<script type="text/javascript" src="Chart.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$.ajax({
//url: "test.html",
//method: "GET",
success: function(data) {
// test data
var data = [
{
"Serverid":"1",
"score":"37"
},
{
"Serverid":"2",
"score":"60"
},
{
"Serverid":"3",
"score":"35"
},
{
"Serverid":"4",
"score":"41"
},
{
"Serverid":"5",
"score":"50"
},
{
"Serverid":"6",
"score":"70"
},
{
"Serverid":"7",
"score":"70"
},
{
"Serverid":"8",
"score":"70"
},
// ... it …Run Code Online (Sandbox Code Playgroud)