Results 1 to 6 of 6

Thread: How to find a correct directory

  1. #1
    Join Date
    May 2007
    Location
    East Coast
    Posts
    22
    Rep Power
    0

    How to find a correct directory

    Hi all.
    I ada satu soalan di sini.I ada form for user to upload their file.I dah run di localhost and success.
    But now i want to make it online.
    The problem is:
    I tak tahu macam mane nak dapatkan correct path/directory untuk simpan file yang telah diupload ke folder upload.

    Here is my coding:

    PHP Code:

    $Submit
    =$_POST['Submit'];
    echo 
    $upload_id=$_GET['upload_id'];
    $action=$_GET['action'];
    echo 
    $upload_name=$_FILES['imagefile']['name'];
    echo 
    $upload_desc=$_POST['upload_desc'];

    $dir "upload";

    $upload_dir $dir."/".$_FILES['imagefile']['name'];
    echo 
    getcwd() . $dir;
    if(
    $Submit=="Submit"){
     
    copy (    $_FILES['imagefile']['tmp_name'], "".$dir."/".$_FILES['imagefile']['name']) or die ("Could not Submit"); 
             echo 
    "";  
            echo 
    "Name: ".$_FILES['imagefile']['name']."<br>";  
            echo 
    "Size: ".$_FILES['imagefile']['size']."<br>";  
            echo 
    "Type: ".$_FILES['imagefile']['type']."<br>";         
            echo 
    "Success....";  
            
            
    $InsertQuery "INSERT INTO file_upload (upload_date,upload_name,upload_desc,upload_dir) VALUES ('$today1','$upload_name','$upload_desc','$upload_dir')";
            
    $Result mysql_query($InsertQuery) or die("<p>Error number ".mysql_errno().": ".mysql_error()."</p>"); 
            
            echo 
    "<META HTTP-EQUIV=Refresh CONTENT=\"2; URL=Resume.php\">";    


    Please let me know how to solve this problem..Thanks in advance

  2. #2
    Join Date
    Oct 2005
    Location
    KLC
    Posts
    91
    Rep Power
    165
    Code:
    $dir = "upload";
    from dat we can see the directory is 'upload'. it should be a sub directory where you have uploaded the php file. if you ftp, you should see the folder 'upload' listed together with the php file you have uploaded. if not, then you should create the folder and chmod it to 775 or 777.

    use

    Code:
    echo _SERVER["SCRIPT_FILENAME"]
    in your php file to find out wher your current script is.

  3. #3
    Join Date
    May 2007
    Location
    East Coast
    Posts
    22
    Rep Power
    0
    Quote Originally Posted by afroman View Post
    Code:
    $dir = "upload";
    from dat we can see the directory is 'upload'. it should be a sub directory where you have uploaded the php file. if you ftp, you should see the folder 'upload' listed together with the php file you have uploaded. if not, then you should create the folder and chmod it to 775 or 777.

    use

    Code:
    echo _SERVER["SCRIPT_FILENAME"]
    in your php file to find out wher your current script is.
    Thanks a lot..
    before this I used direct admin hosting and it works..
    Now I switched to CPanel..the file cannot be submitted..

    This is my directory :$dir="home/domainname/public_html/upload";

    Please tell me more :I put this script but the page just blank.

    echo _SERVER["SCRIPT_FILENAME"]
    Thanks

  4. #4
    Join Date
    Oct 2005
    Location
    KLC
    Posts
    91
    Rep Power
    165
    create a php file and put this code

    <?php
    echo _SERVER["SCRIPT_FILENAME"];
    ?>
    upload it to your server and view file. eg. http://domainname.com/filename.php. it should show something like

    /home/public_html/userlogin/filename.php

    btw, err.. how do you upload your files to the server? i dont understand when u said now u use cpanel instead of directadmin.

  5. #5
    Join Date
    May 2007
    Location
    East Coast
    Posts
    22
    Rep Power
    0
    Quote Originally Posted by afroman View Post

    btw, err.. how do you upload your files to the server? i dont understand when u said now u use cpanel instead of directadmin.
    Thanks a lot Mr afroman..before this I guna directadmin hosting..
    I ambil location file upload tu.
    so path nya:
    $dir="/usr/home/domainname/domains/domainname.com.my/public_html/upload";

    Tapi sekarang I dah tukar ke cPanel..so I dapat path die :

    $dir="home/domainname/public_html/upload";

    Tapi tak dapat nak submit..bila run di localhost success.. so problem kat sini maybe I tak tahu cara betul nak ambil path di dalam cPanel atau mungkin cara I yang tak betul.

    Please let me know..

    Thanks in advance.

  6. #6
    Join Date
    Oct 2005
    Location
    KLC
    Posts
    91
    Rep Power
    165
    echo $_SERVER["SCRIPT_FILENAME"];


    tak perasan takde tande $...

    anyway, sepatut ade slash kat depan.

    buat satu file dan masukkan code ni. upload, then bukak dlm browser. page tu akan display suemr info u nak


    <?php
    phpinfo();
    ?>
    Last edited by afroman; 05-11-2007 at 12:05 AM. Reason: buang pre tag
    klaatu barada nikto

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 6
    Last Post: 31-10-2008, 05:07 PM
  2. where to find
    By misbsl in forum Graphic Design
    Replies: 5
    Last Post: 20-04-2008, 05:26 AM
  3. wat's the correct way to publish site
    By jzkzlz in forum Other Internet Marketing Methods
    Replies: 10
    Last Post: 25-06-2007, 03:52 PM
  4. The correct way to improve PageRank?
    By kahsoon in forum Other Internet Marketing Methods
    Replies: 3
    Last Post: 23-03-2005, 11:48 AM
  5. How did you find your host?
    By Helen in forum Paid Hosting Discussion Forum
    Replies: 10
    Last Post: 29-10-2004, 06:55 PM

Posting Permissions

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

Search Engine Optimization by vBSEO 3.5.0 RC1 PL1

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112