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!

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.