Jump to content

[SOLVED] noob question


lacy

Recommended Posts

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

 

Link to comment
https://forums.phpfreaks.com/topic/172982-solved-noob-question/
Share on other sites

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

 

 

Link to comment
https://forums.phpfreaks.com/topic/172982-solved-noob-question/#findComment-911694
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.