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]"

Link to comment
Share on other sites

<?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

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.