3

I was wondering if it will b possible to Create a HTML upload form and it will be purely HTML without calling any other PHP language to validate it. for example, Normally to create a file upload form is this way. Create an Upload-File Form

Look at the following HTML form for uploading files:

<html>
<body>

<form action="upload_file.php" method="post"
enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file"><br>
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>

While the PHP script will do the rest..

Create The Upload Script

The "upload_file.php" file contains the code for uploading a file: And it will look lyk dis

<?php
if ($_FILES["file"]["error"] > 0)
{
  echo "Error: " . $_FILES["file"]["error"] . "<br>";
  }
else
   {
  echo "Upload: " . $_FILES["file"]["name"] . "<br>";
  echo "Type: " . $_FILES["file"]["type"] . "<br>";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB<br>";
echo "Stored in: " . $_FILES["file"]["tmp_name"];
 }
?>

but i was wondering if it can be possible not to use a PHP script but only an HTML script for example

<html>
<body>

<form action="upload_file.html" method="post"
enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file"><br>
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>

While maybe another html script will do the rest..

I hope u guys can understand my question and give me a reply, Thanks

3 Answers 3

5

HTML doesn't "do" anything. You can create the form in HTML perfectly fine. But if nothing on the server is handling the upload, it's pointless. You need something server-side that does something with the uploaded data; HTML cannot.

Sign up to request clarification or add additional context in comments.

Comments

2

When a file is uploaded to the webserver via an HTML form, it is placed in a temp directory, with a temporary filename. You need a script of some sort (PHP, .jsp, Perl,...) to 'do' something with the file, like placing it in the correct directory with the correct filename. If you don't do this, the webserver will delete this file when the next url is called in your session.

3 Comments

Alright thanks guy. i was thinking HTML can still be handling the upload
@Mrportal HTML is a declarative meta language. It doesn't do anything, it only describes a document format. It neither uploads anything (the browser does) nor can it handle anything server-side.
@Borniet > "it is placed in a temp directory, with a temporary filename." Is it possible to set this temp file to become a permanent file? ex: set the expiration date to infinity?
0

I think, you need client-side scripting to validate file-upload. If it is, then I believe this link will be helpful. Which explains, how to upload file using jQuery

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.