Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function rmNonAlpha($input) {
- return preg_replace("@[^0-9a-zA-Z\s]@", "", $input);
- }
- if(isset($_GET['filepath'])){
- $base_filepath = ""; // Enter here your base filepath (The directory where you want people to be able to read/write files). You should end it with an "/"
- $sanitized_filepath = rmNonAlpha($_GET['filepath']); // Removes non Alpha chars, so stuff like "/" will be ignored, so people won't leave directory
- $full_path = $base_filepath . $sanitized_filepath;
- if(file_exists($full_path)) {
- echo file_get_contents($path);
- } else echo "File doesn't exist";
- } else echo "Filepath Missing";
- ?>
Advertisement
Add Comment
Please, Sign In to add comment