0

So the issue I am having is it seems I cant send the file I want to the server.

I am not sure if I am doing something wrong, but thought I would ask

 <?

$file = file_get_contents($HTTP_POST_FILES['img']);
print $file;

?>

<form action="" method="post">
<input type="file" name="img" />
<input type="submit" value="submit"/>
</form>
2
  • what you're trying to achieve with print $file; ? Commented Oct 27, 2011 at 6:17
  • And use $_FILES not $HTTP_POST_FILES Commented Oct 27, 2011 at 6:53

2 Answers 2

5

You need to set the correct enctype to multipart/form-data on the form if you want to be able to upload files to the server:

<form action="" method="post" enctype="multipart/form-data">
    <input type="file" name="img" />
    <input type="submit" value="submit"/>
</form>
Sign up to request clarification or add additional context in comments.

Comments

2

I am not sure if I am doing something wrong

Sure. You haven't read the manual page.

here you are: http://php.net/upload

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.