Secure File Upload In PHP Web Applications article

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • subzero
    replied
    that script i post there will not let users to upload php chell scripts

    they can't execute php script with out the php in the name...

    Read better mate next time i did tell ya about it

    Leave a comment:


  • makvanpor2000
    replied
    More light pls, i dont stil understand

    Leave a comment:


  • subzero
    replied
    UPLOAD.PHP
    Code:
    <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post" enctype="multipart/form-data" name="file_upload">
    	<input type="file" name="file" id="file">
    	<input type="hidden" name="execute" id="execute">
    	<input type="submit" name="Submit" id="Submit" value="Submit">
    </form>
    
    <?php
    
    // Upload and Rename File
    if (isset($_POST['execute'])) {
     
    $filename = $_FILES["file"]["name"];
    $file_basename = substr($filename, 0, strripos($filename, '.')); // strip extention
    $file_ext = substr($filename, strripos($filename, '.')); // strip name
    $filesize = $_FILES["file"]["size"];
     
    	if (($file_ext == ".doc" || $file_ext == ".docx")  &&  ($filesize < 200000)) {
    		// rename file
    		$newfilename = md5($file_basename) . $file_ext;
     
    		if (file_exists("upload/" . $newfilename)) {
    			// file already exists error
    			$error = "You have already submitted this file.";
    		} else {
    			move_uploaded_file($_FILES["file"]["tmp_name"], "upload/" . $newfilename);
    			echo "File uploaded successfully.";
    		}
    	} elseif (empty($file_basename)) {
    		// file type error
    		$error = "Please select a file to upload.";
    	} else {
    		// file selection error
    		$error = "Only doc, docx, rtf, pdf, and txt files can be submitted online.";
    		unlink($_FILES["file"]["tmp_name"]);
    	}
    }
    ?>
    Easy Dont need too worry no more lol

    32982398u2.gif
    qw9r1q2ur9.zip
    wuiusadf9.txt
    39riweeswikfj.jar

    this works real good can't execute php script with out the php in the name...

    Leave a comment:


  • GiLL
    replied
    Originally posted by Mysterio3 View Post
    thanks Gill. Btw, you still angry? :D
    no why should i angry ?enjoy its life mood change like day and night lol

    Leave a comment:


  • Mysterio
    replied
    thanks Gill. Btw, you still angry? :D

    Leave a comment:


  • Secure File Upload In PHP Web Applications article

    Secure File Upload In PHP Web Applications article
    its pdf file i couldnt upload here because size issue it may help someone

    link is here

Working...
X