Beamlaku Amare
Beamlaku Amare

Reputation: 11

Assigned input Value is not submitted to PHP

I have an HTML form and an input whose type is file, i wanted to assign a value to the input and i did, but when the form is submitted the file will not be submitted with the assigned value. Here is my code:

<form action="card.php"method="post" enctype="multipart/form-data">
<input type = "file" name = "in_img" value = "img/myimage.jpg">
</form>

The receiver PHP is:

$target_file = $target_dir . basename($_FILES["in_img"]["name"]);

And i always see the same error as if the file was not submitted. Please help...?

Upvotes: 1

Views: 57

Answers (1)

B. Desai
B. Desai

Reputation: 16436

For submit file you must have to pass enctype in it. Change you form tag to

<form enctype="multipart/form-data" method="post">
<input type = "file" name = "in_img" value = "img/myimage.jpg">
</form>

Upvotes: 1

Related Questions