help me on this code

Discussion in 'PHP' started by mirosoft1, Feb 9, 2008.

  1. #1



    i use this code to upload image and store it but it gives me an error






    and also the image not appear on the page but the title is appear
    please help me on this
    :confused:
     
    mirosoft1, Feb 9, 2008 IP
  2. jayshah

    jayshah Peon

    Messages:
    1,126
    Likes Received:
    68
    Best Answers:
    1
    Trophy Points:
    0
    #2
    Create a file in your account called latest.txt and CHMOD (set its' permissions) to 777.

    Jay
     
    jayshah, Feb 9, 2008 IP
  3. 2WDH.com

    2WDH.com Active Member

    Messages:
    143
    Likes Received:
    3
    Best Answers:
    5
    Trophy Points:
    68
    #3
    Hi.

    First you can try to set 755 permissions for the folder where you store files. If that doesn't work then you can try to set 777 permissions.

    Suggestion:
    1. Create separate folder for file uploads.
    2. CHMOD that folder to 755 (or 777 if 755 doesn't work for you)
    3. Use move_uploaded_file function like this: move_uploaded_file($_FILES['imagefile']['tmp_name'],"uploadsfolder/latest.img");
     
    2WDH.com, Feb 9, 2008 IP
  4. mirosoft1

    mirosoft1 Well-Known Member

    Messages:
    110
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    101
    #4
    i donot know how i do this??
    please help me
     
    mirosoft1, Feb 10, 2008 IP
  5. 2WDH.com

    2WDH.com Active Member

    Messages:
    143
    Likes Received:
    3
    Best Answers:
    5
    Trophy Points:
    68
    #5
    mirosoft1,

    What control panel do you use for your hosting account?
     
    2WDH.com, Feb 10, 2008 IP
  6. mirosoft1

    mirosoft1 Well-Known Member

    Messages:
    110
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    101
    #6
    cpanel control panel
     
    mirosoft1, Feb 10, 2008 IP
  7. mirosoft1

    mirosoft1 Well-Known Member

    Messages:
    110
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    101
    #7
    i use this code

    <?php

    // Thanks to "imoldgreg at o2 dot co dot uk" for the base 'CHMOD via FTP' script.

    function chmod_open()
    {
    // Use your own FTP info
    $ftp_user_name = 'xxxx';
    $ftp_user_pass = 'xxxxx';
    $ftp_root = '/';
    $ftp_server = 'localhost';
    $conn_id = ftp_connect($ftp_server);
    $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass);
    return $conn_id;
    }

    function chmod_file($conn_id, $permissions, $path)
    {
    if (ftp_site($conn_id, 'CHMOD ' . $permissions . ' ' . $ftp_root . $path) !== false)
    {
    return TRUE;
    }
    else
    {
    return FALSE;
    }
    }

    function chmod_close($conn_id)
    {
    ftp_close($conn_id);
    }

    // CHMOD the required setup files

    // Connect to the FTP
    $conn_id = chmod_open();

    // CHMOD each file and echo the results
    echo chmod_file($conn_id, 777, 'latest.txt') ? 'CHMODed successfully!' : 'Error';
    // Close the connection
    chmod_close($conn_id);

    ?>


    but gives me this error

    Warning: ftp_site() [function.ftp-site]: Could not change perms on latest.txt: No such file or directory in Untitled-1.php on line 19
    Error
     
    mirosoft1, Feb 10, 2008 IP
  8. 2WDH.com

    2WDH.com Active Member

    Messages:
    143
    Likes Received:
    3
    Best Answers:
    5
    Trophy Points:
    68
    #8
    mirosoft1,

    In cPanel you should be able to go to "File Manager", select the folder, click "Change Permissions" link in the right frame and set the needed permissions.
     
    2WDH.com, Feb 10, 2008 IP