Jump to content

php file upload issue


bftwofreak

Recommended Posts

What script?

 

Whenever I see a post where something was mistakenly left out and it was not reviewed by the OP at any point during or after it was posted to discover and correct that mistake, I am reminded of the original Star Trek episode called the "Changeling" where the Nomad probe mistakes Captain Kirk as its' creator, fails to discover its mistake, and fails to correct its mistake - "Must analyze, analyze, sterilize, sterilize, ... [explosion in deep space]"

<?php

error_reporting(E_ALL);

if ($_POST['rand'] == 'updom') {
if ($_FILES['file']['error'] > 0) {
echo 'An error has occured';
} else {
$target_path = $_SERVER['DOCUMENT_ROOT'] . '/uploads/';
$name = $_POST['name'];
$target_path = $target_path . $name; 
move_uploaded_file($_FILES['file']['tmpname'],$target_path);
echo basename($_FILES['file']['name']) . ' has been uploaded successfully';

}
} else {
echo '<form method="post" enctype="multipart/form-data" >
<input type="hidden" name="rand" value="updom" /><br>
Filename: <input type="text" name="name" value="" /><br>
File: <input type="file" name="file" /><br>
<input type="submit" value="Upload" />
</form>';
}

?>

 

My mistake but you don't have to be an ass... I understand that you are a senior programmer, but why be a bastard to the rest of the forum community? Here's the code if anyone else wishes to assist me.

 

Much appreciated

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.