thibz21 Posted August 17, 2006 Share Posted August 17, 2006 i'm beginner in PHP and i have some problems here. this is my coding:<? if (isset($_GET['page'])) { $page = $_GET['page']; } else { $page = 0; } if ($page == "1"){ $filename = addslashes($_POST['filename']); if ($filename=="") { echo("*** No information given! ***"); } else { $data = file ( '$filename' ); echo("*** hello!! ***<br>"); echo("*** $filename ***"); }}else{ ?> <p> </p> <p> </p> <center> <form name= "form1" form method="post"action="<?=$_SERVER['PHP_SELF']?>?page=1"enctype="multipart/form-data?page=1"> <p> <input type="file" name="filename"> </p> <p> </p> <p> <input name="Submit" type="submit" id="Submit" value="Grade" onkeypress="Check()"> //<input type="hidden" id="formaction" value="uploadNow"> <input name="reset" type="reset" id="reset" value="Clear"> </p> </form> </center> <?}?>and the output is here:Warning: file($filename) [function.file]: failed to open stream: No such file or directory in C:\Program Files\xampp\htdocs\grade.php on line 20*** hello!! ****** C:\\\\Documents and Settings\\\\user\\\\Desktop\\\\hardware.txt ***i need to open a file and the location so shown with many slashes (\\\\). why this happen and how to solve this. if u have any other coding that does solve this problem. plz let me know. and since i'm a beginner, plz give full instruction on wat to do, cause i might don't know. advance thanx for ur help. Quote Link to comment Share on other sites More sharing options...
trq Posted August 17, 2006 Share Posted August 17, 2006 Try removing addslashes() for a second to debug your result. Quote Link to comment Share on other sites More sharing options...
thibz21 Posted August 17, 2006 Author Share Posted August 17, 2006 i appreciate ur help... thanx... ur advise worked but still have few problemsfrom:$filename = addslashes($_POST['filename']);i changed to:$filename = $_POST['filename'];and the output was:Warning: file($filename) [function.file]: failed to open stream: No such file or directory in C:\Program Files\xampp\htdocs\grade.php on line 20*** hello!! ****** C:\\Documents and Settings\\user\\Desktop\\navz.txt ***the slashes were less... but there is one more problem... i cannot ignore the whole...//$filename = addslashes($_POST['filename']);because it will not read the filename inserted.... so how? help... thanx... Quote Link to comment Share on other sites More sharing options...
trq Posted August 17, 2006 Share Posted August 17, 2006 Wait a sec. What exactly are you trying to do? You realise that if you move this code to a server it will not work? I mean, you wont be able to open a file on the clients machine.Another problem is you need double quotes around $filename. I don't know how your code is working at all.[code=php:0]$data = file ( "$filename" );[/code]can you post all your current code and any errors? Quote Link to comment Share on other sites More sharing options...
thibz21 Posted August 17, 2006 Author Share Posted August 17, 2006 the whole code is above there.... actually this code will in a server and the client pc will access that page to grade the student according to the marks in the file.... so.... that's the coding about... how am i suppose to do that... i'm just a beginner in PHP... i hope u might help... thanx... Quote Link to comment Share on other sites More sharing options...
trq Posted August 17, 2006 Share Posted August 17, 2006 You will need to upload the file to the server. Quote Link to comment Share on other sites More sharing options...
thibz21 Posted August 17, 2006 Author Share Posted August 17, 2006 yes... i need to upload it to server... how to do that? ??? Quote Link to comment Share on other sites More sharing options...
trq Posted August 17, 2006 Share Posted August 17, 2006 There is a tutorial on [url=http://www.phpfreaks.com/tutorials/36/0.php]this site[/url] which will show you how to upload an image... the process is the same. Quote Link to comment Share on other sites More sharing options...
thibz21 Posted August 17, 2006 Author Share Posted August 17, 2006 thanx... the double quating (") help me to solve the problem to open the file... thanx bro... but i still need to know how this code will work... i mean... i know i made a mistake... i know this won't work because when we accessing the server and the client pc have to send that file to the server to generate the grade into the file and to be send back to client pc... how do i do that? Quote Link to comment Share on other sites More sharing options...
thibz21 Posted August 17, 2006 Author Share Posted August 17, 2006 [quote author=thorpe link=topic=104570.msg417266#msg417266 date=1155798995]There is a tutorial on [url=http://www.phpfreaks.com/tutorials/36/0.php]this site[/url] which will show you how to upload an image... the process is the same.[/quote]thanx alot bro... i really appreciate ur help... i'll refer that web u gave me.... any problems i'll get back to u later... i hope u don't mind i asking question... thanx again bro.... later... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.