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

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
scel
Forum Newbie
Posts: 1
Joined: Wed Jul 08, 2009 11:42 pm

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

Post 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>
SvanteH
Forum Commoner
Posts: 50
Joined: Wed Jul 08, 2009 12:25 am

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

Post by SvanteH »

This forum is not for asking programming related questions.

Post in the correct board and use the

Code: Select all

-tag
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

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

Post by Jonah Bron »

Be sure the file has a .php extension, not .doc or .html
Post Reply