+ Reply to Thread
Results 1 to 10 of 10

Thread: file upload script

  1. #1
    nightscream is offline x10 Lieutenant nightscream is an unknown quantity at this point
    Join Date
    Feb 2006
    Location
    Hallaar, Belgium
    Posts
    474

    file upload script

    I'm creating my own upload script but It won't work
    if I want to upload something i get
    File '' not uploaded
    It's something with the $_FILES i think but don't know how to fix it
    PHP Code:
    if( isset( $_POST['Upload'] )) {
        
    $upload_dir $_SERVER['DOCUMENT_ROOT'] . "images/";
        
    $MaxFileSize 800000000;
        
    $filename $_FILES['file']['name'];
        
    $filesize $_FILES['file']['size'];
        
    $filetmpname $_FILES['file']['tmp_name'];
        
    $allowed_types = array( "jpg""gif""png" );
        
    $filetype substr($filename, -33);
        
    //$Thumb = $_POST['Thumbnail'];
        //$Water = $_POST['Watermarking'];
        
        
    if($filename) {
        echo 
    'test';
        
    $error 0;
            if((
    $filesize $MaxFileSize) | $filesize ) {
                
    $error 1;
                
    $errmsg .= "Your File is to large, (Max File size: 8MB)";
            }
            if( !
    in_array$filetype$allowed_types )) {
                
    $error 1;
                
    $errmsg .= "Your File is the wrong type, (Allowed Types: Gif, Jpg, Png)//change to the allowed types";
            }else  {
                
    $error 0;
            }
            if( 
    $error ) {
                die( 
    "$errmsg);
            }else{                
                
    $num rand19999 );
                
    $new_filename $num.$filename;
                
    $upload move_uploaded_file($filetmpname"$upload_dir.$new_filename");
                if(
    $Thumb ) {
                    
    CreateThumb($filetmpname);
                }
                if(
    $Water ) {
                    
    CreateWatermark($filetmpname);
                }
                if( 
    $upload ) {
                    echo 
    'Upload Succesfull';
                    
    //echo "<meta http-equiv='refresh' content='0'; URL='?image=$upload_dir.$new_filename'>";
                
    }else {
                    die( 
    "Cound not upload the file, please try again" );
                }
            }
        }else{
            echo 
    "File '$filename' not uploaded";
        }
    }
    ?> 
    Last edited by nightscream; 08-07-2006 at 11:44 AM.
    ------------------------------------------------------------------------------------------
    If you have any troubles with a website or a script, just send me a pm.

    I also code websites in xHTML/css, can code javascript and php too if needed

  2. #2
    Chris Z's Avatar
    Chris Z is offline x10 Spammer Chris Z is an unknown quantity at this point
    Join Date
    Sep 2005
    Location
    Alabama, USA
    Posts
    2,802

    Re: file upload script

    darn...i wish i knew more about php, i can't figure out why it's not working, just wait til bryon comes lol
    -Chris Z
    Retired Account Manager


  3. #3
    nightscream is offline x10 Lieutenant nightscream is an unknown quantity at this point
    Join Date
    Feb 2006
    Location
    Hallaar, Belgium
    Posts
    474

    Re: file upload script

    I have it fixed
    ------------------------------------------------------------------------------------------
    If you have any troubles with a website or a script, just send me a pm.

    I also code websites in xHTML/css, can code javascript and php too if needed

  4. #4
    XxUnknownxX is offline x10Hosting Member XxUnknownxX is an unknown quantity at this point
    Join Date
    Aug 2006
    Posts
    22

    Re: file upload script

    nice good job u should tell us how u made the upload script great job

  5. #5
    nightscream is offline x10 Lieutenant nightscream is an unknown quantity at this point
    Join Date
    Feb 2006
    Location
    Hallaar, Belgium
    Posts
    474

    Re: file upload script

    i forgot the enctype= thingy in <form>
    PHP Code:
    if( isset( $_POST['Upload'] )) {
        
    $upload_dir $_SERVER['DOCUMENT_ROOT'] . "/test/images/";
        
    $MaxFileSize 8192000;
        
    $filename $_FILES['file']['name'];
        
    $filesize $_FILES['file']['size'];
        
    $filetmpname $_FILES['file']['tmp_name'];
        
    $allowed_types = array( "jpg""gif""png" );
        
    $filetype substr($filename, -33);
        
        if(
    $filename) {
        
    $error 0;
            if((
    $filesize $MaxFileSize) || $filesize ) {
                
    $error 1;
                
    $errmsg .= "Your File is to large, (Max File size: 8MB)";
            }
            if( !
    in_array$filetype$allowed_types )) {
                
    $error 1;
                
    $errmsg .= "Your File is the wrong type, (Allowed Types: Gif, Jpg, Png)//change to the allowed types";
            }else  {
                
    $error 0;
            }
            if( 
    $error == ) {
                die( 
    "$errmsg);
            }else{                
                
    $num rand19999 );
                
    $new_filename $num.$filename;
                
    $upload move_uploaded_file($filetmpname"$upload_dir$new_filename");
                if( 
    $upload ) {
                    echo 
    'Upload Succesfull';
                    
    //echo "<meta http-equiv='refresh' content='0; URL=?image=$upload_dir$new_filename'>";
                
    }else {
                    die( 
    "Cound not upload the file, please try again" );
                }
            }
        }else{
            echo 
    "File '$filename' not uploaded";
        }
    }
    ?>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Untitled Document</title>
    </head>

    <body>
    <center>
    <form enctype="multipart/form-data" action="uploadform.php" method="post">
    <input type="file" name="file"><br />
    JPG, GIF, PNG uploadable files.<br />
    <input type="checkbox" name="Thumbnail"> Thumbnails option<br />
    <input type="checkbox" name="Watermarking"> Watermarking option<br />
    <input type="submit" name="Upload" value="Upload File">
    </form></center>
    </body>
    </html> 
    Last edited by nightscream; 08-08-2006 at 04:18 PM.
    ------------------------------------------------------------------------------------------
    If you have any troubles with a website or a script, just send me a pm.

    I also code websites in xHTML/css, can code javascript and php too if needed

  6. #6
    XxUnknownxX is offline x10Hosting Member XxUnknownxX is an unknown quantity at this point
    Join Date
    Aug 2006
    Posts
    22

    Re: file upload script

    cool thats a good script i got a question 4 u do u know how to make a log in script thbt logs u to the forum

  7. #7
    nightscream is offline x10 Lieutenant nightscream is an unknown quantity at this point
    Join Date
    Feb 2006
    Location
    Hallaar, Belgium
    Posts
    474

    Re: file upload script

    You mean on your regular website a login box and if you login you will be rederected to the forum and you are logged in?
    ------------------------------------------------------------------------------------------
    If you have any troubles with a website or a script, just send me a pm.

    I also code websites in xHTML/css, can code javascript and php too if needed

  8. #8
    Conor's Avatar
    Conor is offline Lord Of The Keys Conor is an unknown quantity at this point
    Join Date
    Jan 2005
    Location
    Toronto
    Posts
    1,785

    Re: file upload script

    I was kind of looking for something similar like that. I am building a website and want to insert a login box on the homepage and when you login and click on the forums link, you are logged in already as a result of the information you submitted on the homepage.

  9. #9
    XxUnknownxX is offline x10Hosting Member XxUnknownxX is an unknown quantity at this point
    Join Date
    Aug 2006
    Posts
    22

    Re: file upload script

    yea thats wut im lookin for too

  10. #10
    gjohack19 is offline x10Hosting Member gjohack19 is an unknown quantity at this point
    Join Date
    Jan 2011
    Location
    italy
    Posts
    2

    Re: file upload script

    Quote Originally Posted by nightscream View Post
    i forgot the enctype= thingy in <form>
    PHP Code:
    if( isset( $_POST['Upload'] )) {
        
    $upload_dir $_SERVER['DOCUMENT_ROOT'] . "/test/images/";
        
    $MaxFileSize 8192000;
        
    $filename $_FILES['file']['name'];
        
    $filesize $_FILES['file']['size'];
        
    $filetmpname $_FILES['file']['tmp_name'];
        
    $allowed_types = array( "jpg""gif""png" );
        
    $filetype substr($filename, -33);
        
        if(
    $filename) {
        
    $error 0;
            if((
    $filesize $MaxFileSize) || $filesize ) {
                
    $error 1;
                
    $errmsg .= "Your File is to large, (Max File size: 8MB)";
            }
            if( !
    in_array$filetype$allowed_types )) {
                
    $error 1;
                
    $errmsg .= "Your File is the wrong type, (Allowed Types: Gif, Jpg, Png)//change to the allowed types";
            }else  {
                
    $error 0;
            }
            if( 
    $error == ) {
                die( 
    "$errmsg);
            }else{                
                
    $num rand19999 );
                
    $new_filename $num.$filename;
                
    $upload move_uploaded_file($filetmpname"$upload_dir$new_filename");
                if( 
    $upload ) {
                    echo 
    'Upload Succesfull';
                    
    //echo "<meta http-equiv='refresh' content='0; URL=?image=$upload_dir$new_filename'>";
                
    }else {
                    die( 
    "Cound not upload the file, please try again" );
                }
            }
        }else{
            echo 
    "File '$filename' not uploaded";
        }
    }
    ?>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Untitled Document</title>
    </head>

    <body>
    <center>
    <form enctype="multipart/form-data" action="uploadform.php" method="post">
    <input type="file" name="file"><br />
    JPG, GIF, PNG uploadable files.<br />
    <input type="checkbox" name="Thumbnail"> Thumbnails option<br />
    <input type="checkbox" name="Watermarking"> Watermarking option<br />
    <input type="submit" name="Upload" value="Upload File">
    </form></center>
    </body>
    </html> 
    thank you for share

+ Reply to Thread

Similar Threads

  1. max file upload plz help
    By hyeclass in forum Scripts & 3rd Party Apps
    Replies: 7
    Last Post: 07-01-2006, 10:31 AM
  2. URGENT: 80 points for a CGI script
    By Chirantha in forum The Marketplace
    Replies: 13
    Last Post: 12-28-2005, 11:24 AM
  3. [PHP] Creating a File Upload Script
    By o0slowpaul0o in forum Tutorials
    Replies: 17
    Last Post: 10-05-2005, 01:39 AM
  4. Upload file size limit
    By funindia in forum Free Hosting
    Replies: 0
    Last Post: 06-05-2005, 01:06 AM
  5. Upload script
    By joejoe in forum Free Hosting
    Replies: 6
    Last Post: 03-24-2005, 04:20 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers