All pastes #265309 Raw Edit

gilesw

public php v1 · immutable
·published 2006-12-03 04:53 UTC
rendered paste body
<?php$target = "../upload/";$target = $target . basename( $_FILES['uploaded']['name']) ;//start teststry{        //This is our size condition        if ($uploaded_size > 350000){                $error = "Your file is too large";                throw new Exception($error);        }        //check if upload is an image (exif returns positive integer if it is)        if(!exif_imagetype($_FILES['uploaded']['tmp_name'])){                $error = "Your file isn't an image.";                throw new Exception($error);        }}//display error messagecatch (Exception $e) {        echo 'Caught exception: ',  $e->getMessage(), "\n";        exit();        //header("location:upload.html");}try{        if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target)) {                echo "The file ".                basename( $_FILES['uploadedfile']['name']). " has been uploaded";        }        else {                $error = "you file failed to upload";                throw new Exception($error);        }}//display error messagecatch (Exception $e) {     echo 'Caught exception: ',  $e->getMessage(), "\n";}?>