Jump to content


Photo

Image Uploader Tool


  • Please log in to reply
3 replies to this topic

#1 Atlanticas

Atlanticas
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 21 March 2006 - 03:37 AM

Basically looking for a free or low-cost script/tool that I can install on my site, where visitors can upload a picture to a directory on my site. No login needed or access to the file, I just need to be able to desginate where the image is stored and if possible control the format and size. Thanks!

#2 .-INSANE-.

.-INSANE-.
  • Members
  • PipPip
  • Member
  • 29 posts

Posted 21 March 2006 - 03:44 AM

ok well here is my upload script but ur going to have to change it in diff ways
<?PHP
if($_POST['submit']){
$directory = "/home/username/public_html/files/";   // Change this too
$max_file_size = "CHANGE";     //This is in bytes
$allowedfile[] = "CHANGE TO PIC MIME";  
$allowedfile[] = "CHANGE TO PIC MIME";  
$allowedfile[] = "CHANGE TO PIC MIME";  
$allowedfile[] = "CHANGE TO PIC MIME";
$allowedfile[] = "CHANGE TO PIC MIME";
$allowedfile[] = "CHANGE TO PIC MIME"; 
if (is_uploaded_file($_FILES["file"]["tmp_name"])) {    
    if($_FILES["file"]["size"]>$max_file_size) {        
        $is_uploaded = "failed";      
        echo 'Sorry, this file is too large. The maximum filesize is '.$max_file_size.' bytes, although your file is '.$_FILES["file"]["size"].'. ';        
        exit();    
        }    
        if(!in_array($_FILES["file"]["type"],$allowedfile)) {        
            $is_uploaded = "failed";        
            echo 'Sorry, wrong file type, "'.$_FILES["file"]["type"].'" is not allowed. ';      
            exit();  
        }    
        if(file_exists($directory.$_FILES["file"]["name"])) {        
            $is_uploaded = "failed";        
            echo 'Sorry, this file already exists. ';        
            exit();
        if($is_uploaded!="failed") {
               $replace = array("$","%","#","@","!","&","^","*","(",")","-");
            $new = str_replace($replace,"",$_FILES["file"]["name"]);
            $fileName = str_replace(" " , "_" , $new);

        if(! is_dir($directory)){
                mkdir($directory,0777);
            }
        if (move_uploaded_file($_FILES["file"]["tmp_name"], $directory.$fileName)) {
                echo "Your file, ". $fileName ." has successfully been uploaded!  Click <a href=\"".$directory.$fileName."\">Here</a> to view your file.";
            }
    else {
        echo 'Sorry, your file has not uploaded.';
        exit();
        }
    }
} else {
    echo 'There has been an unknown error while uploading';
    exit();
}
}
?>


#3 Atlanticas

Atlanticas
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 24 March 2006 - 10:34 AM

I changed the
$directory = "http://www.mysite.com/test/";
, I copied the code to a blank page and named it upload.php When I went to visit it, I was told:

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Parse error: syntax error, unexpected $end in /home/.sabastian/atlanticas/mysite.com/test/upload.php on line 48[/quote]

What did I do wrong? Thx :)

#4 Atlanticas

Atlanticas
  • Members
  • PipPip
  • Member
  • 11 posts

Posted 23 October 2006 - 11:10 AM

Anyone? :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users