Page 1 of 1

nothing will display in my code if i uploaded a word documen

Posted: Wed Jul 08, 2009 11:45 pm
by scel
nothing will display in my code if i uploaded a word document..


this is the code...


if ($_REQUEST['docsource']=='Document' && $_FILES["document"]["error"]<=0) {
//Sanitize the filename (See note below)
$remove_these = array(' ','`','"','\'','\\','/');
$newname = str_replace($remove_these,'',$_FILES['document']['name']);
//Make the filename unique
$newname = time().mt_rand(1, 10000).'-'.$newname;
//Save the uploaded the file to another location
$upload_path = $_SERVER['DOCUMENT_ROOT']."/uploaded/$newname";
move_uploaded_file($_FILES['document']['tmp_name'], $upload_path);


$word = new COM("word.application") or die("Unable to instantiate Word");
$word->Visible = 0;

//echo str_replace('/','\\',$upload_path);
$word->Documents->Open(str_replace('/','\\',$upload_path));
$temp = $word->Dialogs->Item(228); // returns wdDialogToolsWordCount dialog object
$temp->Execute(); //updates the word count
$count = floatval(preg_replace('/[\$,]/', '', $temp->Words())); //gets the words out of it
$word->ActiveDocument->Close(false);
$word->Quit();

echo "<label>Text Source : Document</label>";
}
else {
$count = 0;
$str = str_replace( array(chr(13).chr(10) , chr(13) , chr(10)) , " " ,$_REQUEST['txt']);
$array = explode(" ", $str);
$count=count($array); echo "<label>Text Source : Textbox</label>";
}
?>
<table width="200" border="0">
<tr>
<td><label>Number of Words</label></td>
<td><b><label><?php
echo $count
?>
</label>
</b></td>
</tr>
<tr>
<td><label>Price per Word</label></td>
<td><b><label><?php
echo $row['currsymbol']." ". $row['price_per_word'];
$priceperword=$row['price_per_word']; ?></label></b>
</td>
</tr>
<tr>
<td><label>Total Cost</label></td>
<td><b><label><?php
$total=$count*$row['price_per_word'];
echo $row['currsymbol']." ".$total;
?>
</label></b></td>
</tr>
</table>

Re: nothing will display in my code if i uploaded a word documen

Posted: Thu Jul 09, 2009 12:25 am
by SvanteH
This forum is not for asking programming related questions.

Post in the correct board and use the

Code: Select all

-tag

Re: nothing will display in my code if i uploaded a word documen

Posted: Thu Jul 09, 2009 1:56 pm
by Jonah Bron
Be sure the file has a .php extension, not .doc or .html