Jump to content

PHP Image Upload Form - not working .. yet no error **solved ... **


techiefreak05

Recommended Posts

A while back, I found an image upload form that i had no use for.. but now I'm wrapping up the building of my website and am in the proccess of finalizing  the last parts, like images. but im having trouble with this code.. it doesnt give me an error, but it doesnt upload:

[code]<?php

//print_r($_POST);

if($_POST["action"] == "Upload Image")
{
unset($imagename);

if(!isset($_FILES) && isset($HTTP_POST_FILES))
$_FILES = $HTTP_POST_FILES;

if(!isset($_FILES['image_file']))
$error["image_file"] = "An image was not found.";


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

if(empty($imagename))
$error["imagename"] = "The name of the image was not found.";

if(empty($error)){
$newimage = "files/uploads/$_SESSION[username]/images/" . $imagename;
echo $newimage;
$result = @move_uploaded_file($_FILES['image_file']['tmp_name'], $newimage);
if(empty($result))
$error["result"] = "There was an error moving the uploaded file.";
}
}
?>
<div id="form">
<form method="POST" enctype="multipart/form-data" name="image_upload_form" action="<?$_SERVER["PHP_SELF"];?>">
<p><input type="file" name="image_file" size="20"></p>
<p><input type="submit" value="-Upload-" name="action"></p>
</form>
</div>[/code]

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.