Question: I want to echo "success" on the same page the form is on if it uploaded correctly, but Im new to php so dont know how its done?

index.php

```
<form action="upload" method="POST">
<input name="field1" placeholder="First name" type="text" />
<input type="submit" name="submit" value="Submit">

```

upload.php

```
    $content = "".$_POST["field1"];
$fp = fopen("upload/test.txt","wb");
fwrite($fp,$content);
fclose($fp);

```

I also need it to redirect back to same page index.php

Answer: 
You cannot do this when using a regular form post. When a form is posted the user navigates away from the current page and is given a new page by the server. The one they were looking at no longer exists, so you cannot inject a message.

If you want to perform the task as you describe you will need to use an AJAX-based file uploader.

See:<https://stackoverflow.com/search?q=php+jquery+ajax+upload>
You will need to use some javascript along with php to get what you are looking for.
[ajax-file-upload-with-php-and-jquery](http://www.sanwebe.com/2012/06/ajax-file-upload-with-php-and-jquery)

I haven't tried it, but at first glance looks like a great place to start.