redfinger Posted May 31, 2013 Share Posted May 31, 2013 Hi all am new here and also new to php and programming in general.l was wondering if someone could help me understand why the fopen() function is not working.Thanks Link to comment Share on other sites More sharing options...
dsonesuk Posted May 31, 2013 Share Posted May 31, 2013 I tried a vulcan mind meld on the monitor, but! all i got was a headache! so if you could supply your code, it would help, don't you think. Link to comment Share on other sites More sharing options...
thescientist Posted May 31, 2013 Share Posted May 31, 2013 error messages too. Link to comment Share on other sites More sharing options...
redfinger Posted May 31, 2013 Author Share Posted May 31, 2013 sorry this is the code <DOCTYPE html><html> <body> <?php$file=fopen("welcome.txt","r");?> </body </html> Link to comment Share on other sites More sharing options...
redfinger Posted May 31, 2013 Author Share Posted May 31, 2013 am still battling with uploading files. it just wont work.this is the index<!DOCTYPE html><html><head><title>Brave Heart</title></head><body><form action="action.php" method="post" class="test1" enctype="multipart/form-data"><label for="file">Filename:</label><input type="file" name="file" id="file"><br><input type="submit" name="submit" value="upload file"></form></body></html> and the upload script<!DOCTYPE html><html><head><title>Backend</title> </head><body> <?phpif ($_FILES["file"]["error"] > 0) { echo "Error: " . $_FILES["file"]["error"] . "<br>"; }else { echo "Upload: " . $_FILES["file"]["name"] . "<br>"; echo "Type: " . $_FILES["file"]["type"] . "<br>"; echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB<br>"; echo "Stored in: " . $_FILES["file"]["tmp_name"]; }?></body></html> please help .thanks Link to comment Share on other sites More sharing options...
jeffman Posted May 31, 2013 Share Posted May 31, 2013 About Post #4: fopen just returns a file resource, not the file contents. If you want to send the file contents to the browser, look at the first example here. Link to comment Share on other sites More sharing options...
jeffman Posted May 31, 2013 Share Posted May 31, 2013 (edited) About Post #5: What results are you getting? Does your error message echo? Have you tried turning on error reporting? Have you tried var_dump($_FILES) to see what, if anything, arrives at your server? Edited May 31, 2013 by Deirdre's Dad Link to comment Share on other sites More sharing options...
redfinger Posted June 2, 2013 Author Share Posted June 2, 2013 about #5 l was able to get the error.. php in w3schools is fun(moving on to cookies now) and great forum too.thanks guys-deirdre's dad Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now