Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.