Page 1 of 2 1 2 LastLast
Results 1 to 15 of 16

Thread: arahan create new folder

  1. #1
    Join Date
    Oct 2002
    Location
    Kuala Lumpur
    Posts
    27
    Rep Power
    0

    Question arahan create new folder

    Ini aku nak bertanya kepada yang berkenaan,

    Aku ada kod untuk buat fail baru. Dan dah berjaya aku test dalam
    website aku.

    Cuma yang aku tak tau nak edit, camner nak tukar kod tu
    supaya aku boleh pula buat folder baru...

    -----------------------------
    $newfile="".$nama_laman.".".php;
    $fp = fopen($newfile,"wb") or problem("Couldn't create file "$newfile"! Please CHMOD the "msg" folder to 666 (rw-rw-rw)!");
    fputs($fp,$content);
    fclose($fp);
    -----------------------------

    ini adalah arahan dalam php untuk membina lamanweb. Tapi macamana nak
    tukar pula, untuk membina folder. Sebab aku nak bina folder dan dalam folder
    tu baru nak bina fail. Aku ada cuba buang arahan ext .php tu.
    Tapi dia tak jadi folder tapi jadi fail tanpa .ext.

    Siapa boleh bantu.

    Lagi satu, macamana pula nak bina 2 fail sekaligus dalam satu kali klik.
    Aku dah cuba tambah $newfile lagi sekali, tapi tak menjadi.
    Hanya satu fail je yang jadi. Arahan kedua tu diabaikan.

    $newfile="".$nama_laman.".".php;
    $newfile="".$link_laman.".".php;

    Terima kasih kepada yang sudi membantu.




    /SELAMAT BERPUASA DAN HARI RAYA/

  2. #2
    Join Date
    Aug 2001
    Location
    KL
    Posts
    8
    Rep Power
    0
    tak sure you dah ada jawapan or tidak.
    tapi takper..jawab ler jugak ek.

    okeh. utk buat folder baru dlm php senang jer.
    Code:
    mkdir ("/path/to/my/dir", 0666);
    so utk soklan u tuh,maybe u leh try nie

    Code:
    $newfolder = "testfolder";
    mkdir ($newfolder, 0666);
    $newfile=$newfolder."/".$nama_laman.".".php;
    $fp = fopen($newfile,"wb") or problem("Couldn't create file "$newfile"! Please CHMOD the "msg" folder to 666 (rw-rw-rw)!");
    fputs($fp,$content);
    fclose($fp);
    tapi u buleh repair code tuh,buat dulu checking folder dah ada ke belum,
    kalau belum create new folder,else takyah create.

  3. #3
    Join Date
    Oct 2002
    Location
    Kuala Lumpur
    Posts
    27
    Rep Power
    0
    tq.. dah berjaya dah..

  4. #4
    Join Date
    Oct 2002
    Location
    Kuala Lumpur
    Posts
    27
    Rep Power
    0

    soalan tambahan

    Ni ada satu lagi soalan tambahan.

    Macamana kod untuk setkan supaya folder yang dah ada dia tak buat lagi? Sebab ikut kod atas tu, dia akan padam folder lama dan buat folder baru dengan nama folder yang sama.

    TQ.

  5. #5
    Join Date
    Aug 2004
    Location
    Kuching, Sarawak
    Posts
    27
    Rep Power
    0

    Alert kalau folder wujud

    if (file_exists($foldername) {
    //kalau gagal
    echo("<script>alert('$foldername ada. Banyak lagi nama lain!');</script>");
    } else {
    //kalau berjaya
    $foldername=$_GET["foldername"];
    @$action=mkdir($foldername);
    @chmod(foldername, 0777);
    @fclose($action);
    http|//www.jelajahborneo.uni.cc
    Semuanya Bermula Di Sini!

  6. #6
    Join Date
    Dec 2006
    Location
    france
    Posts
    47
    Rep Power
    0
    sy ada test satu script buat folder dan jugak file baru..kat localserver mmg jadi elok, but then sy try kat 2 hosting, satu jadi tp satu lg tak jadi..kuar error..Ada sapa tau mengapa kat sesetengah hosting boleh, sesetengah lagi tak boleh? apa punca problem ni?
    Perlukan Website untuk E-biz?
    Belajar membuat web PHP secara percuma di www.mdpai.com

  7. #7
    Join Date
    Jun 2001
    Location
    Mystic Kingdoms
    Posts
    2,749
    Rep Power
    275
    root folder kepada 'tempat nak buat folder' tu allow write ke tak?
    rasanya itu reason dia kot.

  8. #8
    Join Date
    Aug 2004
    Location
    Kuching, Sarawak
    Posts
    27
    Rep Power
    0

    php setup

    Besar kemungkinan juga setting php hosting tersebut, ada yg membenarkan certain function, ada yang tidak membenarkan certain function, cuba check error msg.
    http|//www.jelajahborneo.uni.cc
    Semuanya Bermula Di Sini!

  9. #9
    Join Date
    Dec 2006
    Location
    france
    Posts
    47
    Rep Power
    0
    Quote Originally Posted by mysticmind View Post
    root folder kepada 'tempat nak buat folder' tu allow write ke tak?
    rasanya itu reason dia kot.
    dah allow, dah cuba byk cara;

    pakai mkdir, create folder kat root - FAIL
    pakai mkdir, create folder kat subfolder - WORKED
    pakai ftp_mkdir, create folder kat root ngan subfolder - WORKED

    pakai fopen(), create file - FAIL kat satu hosting, WORKED kat satu hosting

    so, utk create folder tu, aku pakai ftp_mkdir je, sng cerita sbb jadi kat sume hosting yg aku try. Tp fopen tu aku still tak faham. aku cek php_ini(), allow_fopen tu ON je.

    p/s:
    1.script utk create folder dan file tu ada kat root
    2.file tu dicreate dalam folder yg baru dicreate
    3.Aku test kat localserver, mmg semua jadi.

    So, ada sapa2 tahu?
    Perlukan Website untuk E-biz?
    Belajar membuat web PHP secara percuma di www.mdpai.com

  10. #10
    Join Date
    Jan 2003
    Location
    KL
    Posts
    95
    Rep Power
    202
    dude

    sori haritu aku tengah keje. ko try check open_basedir dalam httpd.conf. try set to none.

    kalau itu takleh gak try tengok safe_mode punya setting. try disable bende tu.

    aight, chow.


    Quote Originally Posted by mdpai View Post
    dah allow, dah cuba byk cara;

    pakai mkdir, create folder kat root - FAIL
    pakai mkdir, create folder kat subfolder - WORKED
    pakai ftp_mkdir, create folder kat root ngan subfolder - WORKED

    pakai fopen(), create file - FAIL kat satu hosting, WORKED kat satu hosting

    so, utk create folder tu, aku pakai ftp_mkdir je, sng cerita sbb jadi kat sume hosting yg aku try. Tp fopen tu aku still tak faham. aku cek php_ini(), allow_fopen tu ON je.

    p/s:
    1.script utk create folder dan file tu ada kat root
    2.file tu dicreate dalam folder yg baru dicreate
    3.Aku test kat localserver, mmg semua jadi.

    So, ada sapa2 tahu?

  11. #11
    Join Date
    Oct 2002
    Location
    Kuala Lumpur
    Posts
    27
    Rep Power
    0
    Quote Originally Posted by webek View Post
    if (file_exists($foldername) {
    //kalau gagal
    echo("<script>alert('$foldername ada. Banyak lagi nama lain!');</script>");
    } else {
    //kalau berjaya
    $foldername=$_GET["foldername"];
    @$action=mkdir($foldername);
    @chmod(foldername, 0777);
    @fclose($action);
    Aku try masukkan kod kat atas ni dalam aku punya kod,

    <?php
    $foldername ="contoh";
    mkdir ("$foldername", 0666);
    if (file_exists($foldername) {
    //kalau gagal
    echo("<script>alert('$foldername ada. Banyak lagi nama lain!');</script>");
    } else {
    //kalau berjaya
    $foldername=$_GET["foldername"];
    @$action=mkdir($foldername);
    @chmod(foldername, 0777);
    @fclose($action);
    ?>
    Tapi keluar pulak error

    Parse error: syntax error, unexpected '{' in /home/contoh/test.php on line 4

    Aku dah tak reti nak ejas dah. Letak kod kat bawa pun tak boleh, kat atas pun tak boleh. Ada sesiapa boleh tulun..

  12. #12
    Join Date
    Oct 2002
    Location
    Kuala Lumpur
    Posts
    27
    Rep Power
    0
    Satu lagi, kalau aku cuma guna ko ini je.

    <?php
    mkdir ("contoh", 0666);
    ?>
    Nanti dia akan beri ralat jika folder tu dah ada. Kira oklah tu, tapi aku nak tukar warning dia dengan ayat aku sendiri. Boleh ke? Kat mana aku nak tambah?

    Warning: mkdir(foldername): Permission denied in /home/public_html/contoh/test.php on line 2

    Aku try tukar camni

    Warning: folder $folder tersebut telah ada.

  13. #13
    Join Date
    Aug 2004
    Location
    Kuching, Sarawak
    Posts
    27
    Rep Power
    0
    CUSTOMIZED ERROR MESSAGE
    ======================
    $file="foldername";
    $Error="Error mesej";
    if ($file==FALSE) die($Error);

    CREATE FOLDER ERROR
    =======================
    kod tak tutup kot? Check bawah sekali.

    <?php
    $foldername ="contoh";
    mkdir ("$foldername", 0666);
    if (file_exists($foldername) {
    //kalau gagal
    echo("<script>alert('$foldername ada. Banyak lagi nama lain!');</script>");
    } else {
    //kalau berjaya
    $foldername=$_GET["foldername"];
    @$action=mkdir($foldername);
    @chmod(foldername, 0777);
    @fclose($action);
    } //missing?
    ?>
    http|//www.jelajahborneo.uni.cc
    Semuanya Bermula Di Sini!

  14. #14
    Join Date
    Oct 2002
    Location
    Kuala Lumpur
    Posts
    27
    Rep Power
    0
    Okey, tq.

    Aku dah jumpa kat mana error dia.

    if (file_exists($foldername) {

    Aku terlupa nak tutup ) kat situ. Ada dua ( ( , tapi aku tutup satu je.



    Quote Originally Posted by webek View Post
    CUSTOMIZED ERROR MESSAGE
    ======================
    $file="foldername";
    $Error="Error mesej";
    if ($file==FALSE) die($Error);

    CREATE FOLDER ERROR
    =======================
    kod tak tutup kot? Check bawah sekali.

    <?php
    $foldername ="contoh";
    mkdir ("$foldername", 0666);
    if (file_exists($foldername) {
    //kalau gagal
    echo("<script>alert('$foldername ada. Banyak lagi nama lain!');</script>");
    } else {
    //kalau berjaya
    $foldername=$_GET["foldername"];
    @$action=mkdir($foldername);
    @chmod(foldername, 0777);
    @fclose($action);
    } //missing?
    ?>

  15. #15
    Join Date
    Aug 2006
    Location
    Malaysia
    Posts
    1,576
    Rep Power
    188
    Good. Just need to check the code syntax around the [line number].
    "Parse error: syntax error, unexpected '{' in /home/contoh/test.php on line 4"

Page 1 of 2 1 2 LastLast

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. One Must Contemplate Upon Folder
    By bryanfuller in forum Other Webmaster-related Services and Promotion
    Replies: 0
    Last Post: 22-12-2009, 09:09 AM
  2. Creativity IS Another Name of Folder
    By muqtada123 in forum Other Webmaster-related Services and Promotion
    Replies: 0
    Last Post: 24-11-2009, 07:35 AM
  3. rack cards printing, presentation folder printing, folder printing
    By muqtada123 in forum Other Webmaster-related Services and Promotion
    Replies: 0
    Last Post: 01-09-2009, 05:45 AM
  4. Looking for Designer to redesign folder
    By BSIS Limited in forum Looking To Hire
    Replies: 0
    Last Post: 26-03-2009, 12:28 AM
  5. Replies: 10
    Last Post: 09-08-2008, 10:56 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