lacy Posted September 3, 2009 Share Posted September 3, 2009 Hi I am learning php, trying to upload a file, read it into a variable, and display it simultaneously heres the code $target = "uploads/"; $target = $target . basename( $_FILES['file']['name']) ; $ok=1; echo "welcome"; if(move_uploaded_file($_FILES['file']['tmp_name'], $target)) { echo "The file ". basename( $_FILES['file']['name']). " has been uploaded"; } else echo "error"; $data=$_FILES[logfile][name]; $fh=fopen($data, 'r'); $current_line = fgets($fh); while (!feof($fh)) { $values = fread($fh, 8192); echo $values; } and when i run it, am getting infinte loop of these errors Warning: feof(): supplied argument is not a valid stream resource Please help Quote Link to comment https://forums.phpfreaks.com/topic/172982-solved-noob-question/ Share on other sites More sharing options...
ignace Posted September 3, 2009 Share Posted September 3, 2009 $data=$_FILES[logfile][name]; (more appropriate syntax is: $data=$_FILES['file']['name']; and not logfile but file) should be: $data=$target; Quote Link to comment https://forums.phpfreaks.com/topic/172982-solved-noob-question/#findComment-911687 Share on other sites More sharing options...
lacy Posted September 3, 2009 Author Share Posted September 3, 2009 Hi thanks a bunch for your answer. I made the changes and i now dont have that infinite loop of feof errors but its not uploading the file and triggering the error message i put in the if loop saying the file cannot be uploaded. can you suggest me what to do in this case Quote Link to comment https://forums.phpfreaks.com/topic/172982-solved-noob-question/#findComment-911694 Share on other sites More sharing options...
ignace Posted September 3, 2009 Share Posted September 3, 2009 mark it as solved please. Quote Link to comment https://forums.phpfreaks.com/topic/172982-solved-noob-question/#findComment-911700 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.