Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    Regular Coder
    Join Date
    Mar 2004
    Location
    Australia
    Posts
    217
    Thanks
    0
    Thanked 1 Time in 1 Post

    Problem with uploading

    PHP Code:

        $uploaddir 
    "includes/pages/demos"// destination of demo
        
    $allowed_ext "gif, jpg, jpeg, bmp"// file extension
        
    $max_size "10000000"// size

        // Check Entension
        
    $extension pathinfo($_FILES['txtScreenshot']['name']);
        
    $extension $extension[extension];
        
    $allowed_paths explode(", "$allowed_ext);
        for(
    $i 0$i count($allowed_paths); $i++) {
         if (
    $allowed_paths[$i] == "$extension") {
         
    $ok "1";
         }
        }

        
    // Check File Size
        
    if ($ok == "1"
        {
            if(
    $_FILES['txtScreenshot']['size'] > $max_size)
            {
                
    // size is too big
            
    }

            
    // The Upload Part
            
    if(is_uploaded_file($_FILES['txtScreenshot']['tmp_name']))
            {
                
    move_uploaded_file($_FILES['txtScreenshot']['tmp_name'],  $uploaddir '/' $steam_id "." $key ".screenshot" $extension);
            }

            
    // successfull
        

        else 
        {
            
    // error
        

    Hey. I have the above code that i am trying to use to upload a screenshot from a demo. all the user needs to do is locate the screenshot on their pc and click upload. im just wondering if you can see any problems with it. i keep hitting the error at the end.

    thanks

  • #2
    Regular Coder
    Join Date
    May 2005
    Posts
    563
    Thanks
    0
    Thanked 3 Times in 3 Posts
    add

    PHP Code:
    break; 
    after this line

    PHP Code:
    $ok "1"

  • #3
    Regular Coder
    Join Date
    May 2005
    Posts
    563
    Thanks
    0
    Thanked 3 Times in 3 Posts
    better still... replace

    PHP Code:
    for($i 0$i count($allowed_paths); $i++) { 
        if (
    $allowed_paths[$i] == "$extension") { 
            
    $ok "1"
        } 

    with

    PHP Code:
    if (in_array($extension,$allowed_paths)) { 
        
    $ok "1"
    } else {
        
    $ok "0";


  • #4
    Regular Coder
    Join Date
    Mar 2004
    Location
    Australia
    Posts
    217
    Thanks
    0
    Thanked 1 Time in 1 Post
    ok that didnt seam to make any difference to the end result. any other ideas?

  • #5
    Regular Coder
    Join Date
    May 2005
    Posts
    563
    Thanks
    0
    Thanked 3 Times in 3 Posts
    What is this line supposed to be doing?

    PHP Code:
    $extension $extension[extension]; 
    replace

    PHP Code:
    $extension pathinfo($_FILES['txtScreenshot']['name']); 
    $extension $extension[extension]; 
    with

    PHP Code:
    $extension explode(".",$_FILES['txtScreenshot']['name']); 
    $extension $extension[(count($extension) - 1)]; 

  • #6
    Regular Coder
    Join Date
    Mar 2004
    Location
    Australia
    Posts
    217
    Thanks
    0
    Thanked 1 Time in 1 Post
    thanks for that. however still not the problem. i have a feeling that it could be the dir im trying to upload too.

    is there a way i can tell a file to upload a file to say

    [ current file path ] / images

    without having to link the whole

    home/www/...../dev/.. ect

  • #7
    Regular Coder
    Join Date
    Jul 2004
    Posts
    134
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation

    What should we choose?
    FORM based upload or by establishing a FTP connection.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •