Jump to content

Need a simple image upload script


webref.eu

Recommended Posts

Here's a very simple, "barebone" script to get the job done.  Although it shouldn't be used as-is, it's at least a place for you to start.

 

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title>Simple Upload Script</title>
  <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
</head>
<body>

<?php

if(isset($_POST['submit'])) {

$dir = "upload/"; // this directory needs to exist and permissions need to be 0777

$imagename = basename($_FILES['image']['name']);

$newimage = $dir.$imagename;

move_uploaded_file($_FILES['image']['tmp_name'], $newimage);

}

?>

<form method="POST" enctype="multipart/form-data"  action="">

<input type="file" name="image" /><br />
<input type="submit" name="submit" value="UPLOAD IMAGE" />

</form>

</body>
</html>

 

Hope this helps!

Link to comment
Share on other sites

The above codes r nt secured be careful or add some blacklists to stop hackers to upload stufs that wud destroy everythin u got.

 

Right, which is why I said that it is a place for him to start, and shouldn't be used as-is.

Link to comment
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.