1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

how to give full permission of any file on server

Discussion in 'PHP' started by dineshsingh1984, Feb 23, 2011.

  1. #1
    I'm create a upload file page where show this error when submit

    I want full permission (777) from ftp but it's not working and server's side said i'm giving full permission to all file but on ftp display only 645 permission.
    I'm attach my prob with an image
    plz give solution........
     
    dineshsingh1984, Feb 23, 2011 IP
  2. tvoodoo

    tvoodoo Active Member

    Messages:
    239
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    53
    #2
    Dude , are you insane ?
    I mean its for blind people to see this problem. So basically you are trying to upload a file to the folder ../upload , meaning it should be in D:\Domains\....\....\upload\ (which is at the same level as wwwroot). Does that folder exist ? if it doesn't then instead of uploading the files to ../upload just upload them to upload/ and as the code was yesterday when I changed it for you , it will work fine.
     
    tvoodoo, Feb 23, 2011 IP
  3. ap2010

    ap2010 Guest

    Messages:
    41
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I agree with tvoodoo. First thing's first, check for the presence of the ../upload directory. Or may be you want ./upload.
     
    ap2010, Feb 23, 2011 IP
  4. dineshsingh1984

    dineshsingh1984 Active Member

    Messages:
    154
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #4
    hey dude I am trying your all method
    first using this type path D:\Domains\....\....\upload\
    and other using this type path ../uplaod/
    and third using path ./upload/
    and my coding is .......................
    <?php
        include ('db.php');
        include ('image_thumb.php');
        $name = $_POST['name'];
        $from = $_POST['email'];
        $file = $_POST['fileone'];
       
        if(isset($_FILES['fileone']) && $_FILES['fileone']['size'] > 0)
        {
            $sql = 'SELECT max(id) "mid" FROM upload';
            $rs_mycorner1 = mysql_query($sql) or die("this is selection error");
            $rs_mycorner2 = mysql_fetch_array($rs_mycorner1);  
            $mycorner_id = $rs_mycorner2['mid'];
            $mycorner_id = $mycorner_id + 1;
               
            $files=$_FILES['fileone']['name'];
            $info = pathinfo($files);
            $file_name =  basename($files,'.'.$info['extension']);
           
            $filename=stripslashes($files);
            $extention=getExtenstion($filename);
            $extention=strtolower($extention);
            $image_name = $file_name.'_'.$mycorner_id.'.'.$extention;
           
            if(!file_exists("../upload"))
                mkdir("../upload");
           
            if(move_uploaded_file($_FILES['fileone']['tmp_name'],"../upload/".$image_name))
            {
                $rs = mysql_query("insert into upload set name='{$_POST['name']}', email='{$_POST['email']}', file='{$image_name}'") or die("Additional error");
                if(mysql_affected_rows() == 1)
                {
                    echo "one record added sucessfully";
                } else if(mysql_affected_rows() == 0) {
                    $rsc=mysql_query("select max(id) as idno from upload") or die("selection error");
                    $rec=mysql_fetch_array($rsc);
                    $files = $rec['idno'];
                   
                    $sqld="select * from upload where id='{$files}'";
                    $rsd=mysql_query($sqld) or die("other selection error");
                    $red=mysql_fetch_array($rsd);
                    $filess=$red['file'];
                    $to="info@rdmemorialphysio.com";
                    $subject="Resume";
                    $message="<b>"."Resume : "."</b>"."http://rdmemorialphysio.com/upload/".$filess;
                    $message = str_replace("\n", "<br>",$message);
                   
                    $mime_boundary="==Multipart_Boundary_x".md5(mt_rand())."x";
                    // now we'll build the message headers
                    $headers =  "From: $from\r\n" . 'Reply-To: $from' .
                                "MIME-Version: 1.0\r\n" .
                                "Content-Type: multipart/mixed;\r\n" .
                                " boundary=\"{$mime_boundary}\"";
                   
                    $message =  "This is a multi-part message in MIME format.\n\n" .
                                "--{$mime_boundary}\n" .
                                "Content-Type: text/html; charset=utf-8\"\n" .
                                "Content-Transfer-Encoding: 7bit\n\n" .
                    $message . "\n\n";
                    $message.="--{$mime_boundary}--\n";
                   
                    /*
                    ini_set("SMTP","173.244.173.138");
                    ini_set("smtp_port","25");
                    ini_set("sendmail_from","akashcreations@gmail.com");
                    */
                    $m = @mail($to, $subject, $message, $headers);
                    if($m)
                    {
                        echo '  <script language="javascript" type="text/javascript">
                                alert("Mail sent successfully.")
                                location.replace("upload.php");
                                </script>';  
                    } else {
                        echo '  <script language="javascript" type="text/javascript">
                                alert("There is server error ! Plz Try Again.")
                                location.replace("upload.php");
                                </script>';    
                    }
                } else {
                    echo "no row insert";
                }
            } else {
                echo "An error occurred when we tried to save the uploaded"."<br>";
            }
        }
    ?>
    PHP:
     
    dineshsingh1984, Feb 24, 2011 IP
  5. yohanip

    yohanip Well-Known Member

    Messages:
    350
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    108
    #5
    try using this handy php function to test your current working environtment..
    getcwd()
    PHP:
    now that you are using relative path, try to print out the realpath of your relative path simply by using the function
    realpath(../upload)
    PHP:
    from there you should see which foldere you need to give full permission the devilish 777 permission :)
     
    yohanip, Feb 24, 2011 IP
  6. ap2010

    ap2010 Guest

    Messages:
    41
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Instead of checking

    file_exists("../upload")
    PHP:
    check

    is_dir("../upload")
    PHP:
    You must have permissions to create folder in the "../" directory, whatever that is.
     
    ap2010, Feb 24, 2011 IP
  7. srisen2

    srisen2 Peon

    Messages:
    359
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #7
    try using suphp as this resolves most upload permission issues by giving you full access without needing 777 permissions
     
    srisen2, Feb 24, 2011 IP