Note that there are some explanatory texts on larger screens.

plurals
  1. POopening and viewing a file in php
    primarykey
    data
    text
    <p>how do i open/view for editing an uploaded file in php?</p> <p>i have tried this but it doesn't open the file.</p> <pre><code>$my_file = 'file.txt'; $handle = fopen($my_file, 'r'); $data = fread($handle,filesize($my_file)); </code></pre> <p>i've also tried this but it wont work.</p> <pre><code>$my_file = 'file.txt'; $handle = fopen($my_file, 'w') or die('Cannot open file: '.$my_file); $data = 'This is the data'; fwrite($handle, $data); </code></pre> <p>what i have in mind is like when you want to view an uploaded resume,documents or any other ms office files like .docx,.xls,.pptx and be able to edit them, save and close the said file.</p> <p>edit: latest tried code...</p> <pre><code> &lt;?php // Connects to your Database include "configdb.php"; //Retrieves data from MySQL $data = mysql_query("SELECT * FROM employees") or die(mysql_error()); //Puts it into an array while($info = mysql_fetch_array( $data )) { //Outputs the image and other data //Echo "&lt;img src=localhost/uploadfile/images".$info['photo'] ."&gt; &lt;br&gt;"; Echo "&lt;b&gt;Name:&lt;/b&gt; ".$info['name'] . "&lt;br&gt; "; Echo "&lt;b&gt;Email:&lt;/b&gt; ".$info['email'] . " &lt;br&gt;"; Echo "&lt;b&gt;Phone:&lt;/b&gt; ".$info['phone'] . " &lt;hr&gt;"; //$file=fopen("uploadfile/images/".$info['photo'],"r+"); $file=fopen("Applications/XAMPP/xamppfiles/htdocs/uploadfile/images/file.odt","r") or exit("unable to open file");; } ?&gt; </code></pre> <p>i am getting the error:</p> <pre><code>Warning: fopen(Applications/XAMPP/xamppfiles/htdocs/uploadfile/images/file.odt): failed to open stream: No such file or directory in /Applications/XAMPP/xamppfiles/htdocs/uploadfile/view.php on line 17 unable to open file </code></pre> <p>the file is in that folder, i don't know it wont find it.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload