I'm trying to get data from a file that is stored on the users computer c:\Report.csv

This is hte code.


$filename = 'C:\\Report.csv';
$handle = fopen ($filename, 'rb');

//	Test of Explode
$line = fread ($handle,2025);
$part = explode ('"',$line);
echo '<br><br><br><br>';
echo $part[49];

I get the following error:

Warning: fopen("C:\Report.csv", "rb") - No such file or directory in /home/sysfrog/public_html/Totland/standardbrev/prove.php on line 24

Line 24 is $handle.....

I'm using a unix server.

Why does this work on a Win server and not unix?!?

Kj.

    PHP is a server side scripting language. What your code is doing is trying to open the file on the server, which since it's unix doesn't have a c:\, and even if it did wouldn't do what you are wanting. You should create a form that will allow the user to upload the file to your server.

      Is there any way around this?

      Is it possible to read a file from the users computer and use it in the script??

      If it doesn't work with fopen, is there any other function I could use???

      Kj.

        its not that it won't work with fopen(), it is the way you want it to work, you can't just grab a file from a clients computer and work with it, you must have the client upload the file, then you can use fopen() with that file once it is uploaded, that would create great security problems if it worked the way you want it to

          I am glad there is no such PHP function to access a file on the viewer's PC without their permission. Unfortunately, ActiveX is not so polite.

          Have the user upload the file with a POST form.

            I agree with both of you on the security question.

            My script is meant for inhouse use. I'm trying to make a task easyer when today. Uploading would make it even more difficult when today (using MS Word and it's mail merger function).

            We have a system that is able to make *.csv files with the customer information. Unfortunatly I'm not allowed even reading access to the database :-(. In my web based system, based on php and mysql, I have stored all standard letters which I hoped to "merge" the customer information with the script above.

            If you guy's are right, this would not work?!? (Other suggestions then upload the file??)

            However, why does this work on Apache on Win2000?!?

            Kj.

              However, why does this work on Apache on Win2000?!?

              You check this on the same machine, working as a client and as a server, don't you?
              So, you do not take the file from client but from server machine.

              Gregor63

                Write a Reply...