$f="../mts/sites/default/files/test.doc";
//以这种方式我能够找到行数,但我没有得到如何我可以给文件夹路径行计数..如果我给路径为$safe_filename
和$target_path.$safe_filename
它来的文件内容不是开幕。请检查代码,并帮助我在此先感谢行数路径问题
<?php
$nid = 1;
$teaser = false;
// Load node
$node = node_load(array('nid' => $nid));
// Prepare its output
if (node_hook($node, 'view')) {
node_invoke($node, 'view', $teaser, false);
}
else {
$node = node_prepare($node, $teaser);
}
// Allow modules to change content before viewing.
node_invoke_nodeapi($node, 'view', $teaser, false);
// Print
print $teaser ? $node->teaser : $node->body;
$target_path = "../mts/sites/default/files/ourfiles/";
//$myfile = basename($_FILES['uploadedfile']['name']);
$safe_filename = preg_replace(
array("/\s+/", "/[^-\.\w]+/"),
array("_", ""),
trim($_FILES['uploadedfile']['name']));
$target_path = $target_path.$safe_filename;
if(file_exists($target_path))
{
echo "<script language=\"javascript\">";
echo "window.alert ('File already exist');";
echo "//--></script>";
}
elseif(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "<script language=\"javascript\">";
echo "window.alert ('File uploaded succesfully');";
echo "//--></script>";
/*
echo "The file ". basename($_FILES['uploadedfile']['name']).
" has been uploaded";
*/
}
$con = mysql_connect("localhost","mts","mts");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
// Create table
mysql_select_db("mts", $con);
$f="../mts/sites/default/files/test.doc";//in this way i am able to find line count,but i am not getting how i can give folder path for line counting
// count words
$numWords = str_word_count($str)/11;
echo "This file have ". $numWords . " words";
echo "This file have ". $numWords . " lines";
mysql_query("INSERT INTO mt_upload (FileName,linecount, FilePath,DateTime)
VALUES ('".$safe_filename."','".$numWords."', '".$target_path.$safe_filename."',NOW())");
// Execute query
mysql_query($sql,$con);
mysql_close($con);
?>
强调文本
您的示例代码缺少一些内容,可能会缺少一些其他内容。代码示例应该是最小的测试用例,这意味着它们是完整的,说明了问题,但不包含比必要更多的代码。所有与节点有关的东西看起来与你的问题无关。 – outis 2009-11-16 09:50:47
如何在不打开文件的情况下“发送”内容?另外,如何在不计算线的情况下“找到”线数呢? – 2009-11-16 10:48:02