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

Thread: upload file

  1. #1
    Join Date
    Feb 2004
    Location
    Klang Bandar Diraja
    Posts
    160
    Rep Power
    194

    upload file

    i got an upload image parse from php freaks but my image can't uploaded... error found said : you didn't select anu file...

    --------------------upload image parse---------------------------

    <?php
    include 'Connections/star.php';
    session_start();

    if (empty($_SESSION['user_name']))
    {
    echo "<center><font color=red face=tahoma><strong>Sila login!</strong></font></center></br>";
    include ("index.php");
    exit();
    }

    $user_id = $_SESSION['user_id'];
    $maxfile_size = 81920;
    $photo_path = "C:/phpdev/www/star/profile_photo/";

    //check if there was a file uploaded
    if(!is_uploaded_file($_FILES['user_photo']['temp_name']))
    {
    $error = 'anda tidak memilih sebarang fail';
    //if it was go ahead with another check
    }
    else
    {
    if($_FILES['user_photo']['size'] > $maxfile_size)
    {
    $error = 'Fail anda terlalu besar.<br/>';
    unlink($_FILES['user_photo']['temp_name']);
    }
    else
    {
    $ext = strrchr($_FILES['user_photo']['name'],".");
    if($ext != ".GIF" AND $ext != ".JPG" AND $ext != ".JPEG" AND $ext != ".BMP" AND
    $ext != ".gif" AND $ext != ".jpg" AND $ext != ".jpeg" AND $ext != ".bmp")
    {
    $error = 'Fail anda tidak menepati format fail';
    unlink($_FILES['user_photo']['temp_name']);
    }
    else
    {
    if ($_SESSION['user_photo'] != 'question.gif')
    {
    unlink($photo_path.$_SESSION['user_photo']);
    }
    $newname = $_SESSION['user_id'].$ext;
    move_uploaded_file($_FILES['user_photo']['temp_name'],$photo_path.$newname);
    $photo_query = mysql_query("UPDATE user_mgt
    SET user_photo ='$newname'
    WHERE user_id = $user_id") or die(mysql_error());
    $_SESSION['user_photo'] = $newname;
    }
    }
    }
    ?>
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <style type="text/css">
    <!--
    @import url("css/New%20Folder.css");
    -->
    </style>
    </head>

    <body>
    <TABLE WIDTH=800 BORDER=0 align="center" CELLPADDING=0 CELLSPACING=0>
    <TR>
    <TD height="178" COLSPAN=3><div align="center">
    <table width="790" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td width="790" height="178"><table width="591" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
    <td width="21" height="19" valign="bottom"><img src="web%20design/images/bannerbox_03.gif" width="21" height="18"></td>
    <td width="539" height="20" valign="bottom"><img src="web%20design/images/bannerbox_04.gif" width="738" height="18"></td>
    <td width="31" valign="bottom"><img src="web%20design/images/bannerbox_05.gif" width="31" height="18"></td>
    </tr>
    <tr>
    <td height="133" background="web design/images/bannerbox_06.gif">&nbsp;</td>
    <td background="web design/images/bannerbox_07.gif"><p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p></td>
    <td background="web design/images/bannerbox_08.gif"></td>
    </tr>
    <tr>
    <td><img src="web%20design/images/bannerbox_09.gif" width="21" height="25"></td>
    <td background="web design/images/bannerbox_10.gif">&nbsp;</td>
    <td><img src="web%20design/images/bannerbox_11.gif" width="31" height="25"></td>
    </tr>
    </table></td>
    </tr>
    </table>
    </div></TD>
    </TR>
    <TR>
    <TD height="24" colspan="3" valign="top"><form name="login" action="checkuser.php" method="post">
    <table width="781" height="24" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#996600">
    <tr>
    <td width="751" height="22" align="left" valign="bottom" bgcolor="#FFCC00" class="custom"><p align="center"><a href="member.view.profile.php">]
    lihat profai l [</a> |<a href="member.edit.profile.php"> ] kemaskini
    profail [</a> | <a href="change.photo.php">] kemaskini gambar
    [</a> |<a href="logout.php"> ] tukar katalaluan ? [ </a>| <a href="logout.php">]
    keluar [</a> </p></td>
    </tr>
    </table>
    </form></TD>
    </TR>
    <TR>
    <TD width="165" valign="top"> <p>&nbsp;</p>
    <table width="160" height="265" border="0" cellpadding="0" cellspacing="0" class="leftmenu" id="Right_menu">
    <tr>
    <td width="1286" valign="top"> <p>&nbsp;</p>
    <table width="150" height="179" border="0" align="center" cellpadding="2" cellspacing="0" bordercolor="#0066FF" bgcolor="#FFFFFF">
    <tr>
    <td valign="top" bgcolor="#CDB085"><p align="center">
    <?php
    $photo = $_SESSION['user_photo'];
    $photo_name = stripslashes($photo);
    ?>
    <img name="gambar_anda" width="100" height="100" alt=<?php echo $_SESSION['user_name'];?> style="background-color: #FFFFFF" src=<?php echo "/star/profile_photo/$photo_name" ?> ></p>
    <p class="custom"> Selamat Datang </p>
    <p class="custom"><?php echo $_SESSION['user_name'];?></p>
    <span class="para">Waktu : &nbsp; <?php echo date("h:i:s A");?>
    <br>
    Tarikh : &nbsp; <?php echo date(" d M Y");?> <br>
    <?php
    $day = date ("l");
    switch ($day)
    {
    case 'Monday' : $today = 'Isnin';
    break;
    case 'Tuesday' : $today = 'Selasa';
    break;
    case 'Wednesday' : $today = 'Rabu';
    break;
    case 'Thursday' : $today = 'Khamis';
    break;
    case 'Friday' : $today = 'Jumaat';
    break;
    case 'Saturday' : $today = 'Sabtu';
    break;
    case 'Sunday' : $today = 'Ahad';
    break;
    }
    ?>
    Hari : <?php echo $today; ?></span></td>
    </tr>
    </table>
    <p>&nbsp;</p>
    <table width="150" border="0" cellpadding="0" cellspacing="0" bgcolor="#FF9900">
    <tr>
    <td bgcolor="#663300" class="titlename"><div align="right"><font size="2">MENU
    AHLI</font></div></td>
    </tr>
    </table>
    <table width="150" border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td><div align="right" class="content"><a href="find.members.php">cari
    rakan</a></div></td>
    </tr>
    <tr>
    <td><div align="right" class="content"><a href="annc.list.php">pengunguman</a></div></td>
    </tr>
    <tr>
    <td><div align="right" class="content">aktiviti </div></td>
    </tr>
    <tr>
    <td><div align="right" class="content">pautan</div></td>
    </tr>
    </table>
    <?php
    if ($_SESSION['user_level'] == 1)
    {
    echo "<table width=150 border=0 cellspacing=0 cellpadding=6>
    <tr>
    <td bgcolor=#663300 class=titlename><div align=right><font size=2><a href = ../admin/admin.index.php>MENU ADMIN </div></a>
    </td>
    </tr>
    </table>";
    }
    ?>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p></td>
    </tr>
    </table>
    <p>&nbsp;</p></TD>
    <TD width="708" valign="top"> <div align="center">
    <p>&nbsp;</p>
    </div>
    <div align="center"></div>
    <table width="450" border="0" align="center" cellpadding="0" cellspacing="0" class="maincontentbox">
    <tr class="maincontentbox">
    <td> <table width="270" border="0" align="center" cellpadding="2" cellspacing="0" class="viewbox">
    <tr>
    <td>
    <?php
    if ($error)
    {
    echo "Gambar anda tidak boleh dikemaskini kerana ".$error.".";
    }
    else
    {
    echo "Gambar anda telah berjaya dikemaskinikan.";
    $photo = $_SESSION['user_photo'];
    $photo_name = stripslashes($photo);
    ?>
    <img name="gambar_anda" width="100" height="100" alt=<?php echo $_SESSION['user_name'];?> style="background-color: #FFFFFF" src=<?php echo "/star/profile_photo/$photo_name" ?> >
    <?php
    }
    ?>
    </td>
    </tr>
    </table></td>
    </tr>
    </table>
    <p>&nbsp;</p></TD>
    <TD width="170" valign="top"><table width="160" height="784" border="0" cellpadding="0" cellspacing="0" id="Left Menu">
    <tr>
    <td width="160" height="784" valign="top"> <p>&nbsp;</p>

    </td>
    </tr>
    </table>
    <p>&nbsp;</p></TD>
    </TR>
    <TR bgcolor="#FFCC33">
    <TD COLSPAN=3><div align="right"><font size="2" face="Arial, Helvetica, sans-serif">Copyright
    2004. All Right Reserved, OnePixel(M) System Sdn. Bhd</font> </div></TD>
    </TR>
    </TABLE>
    <p>&nbsp;</p>
    </body>
    </html>
    To follow the path:
    Look to the master,
    Follow the master,
    Walk with the master,
    See through the master,
    Become the master.

  2. #2
    Join Date
    Feb 2004
    Location
    Klang Bandar Diraja
    Posts
    160
    Rep Power
    194
    here is the html code

    --------------------------------------this is html form to upload file----

    <form name="form1" method="post" action="changephoto.parse.php">
    <p>&nbsp;</p>
    <table width="324" border="0" align="center" cellpadding="2" cellspacing="0" bordercolor="#FFFFFF" class="viewbox">
    <tr>
    <td><p class="para">Gambar anda mestilah kurang daripada 80Kb
    dan berformat : .jpg, .jpeg, .bmp dan .bmp sahaja</p>
    <table width="302" border="0" align="center" cellpadding="2" cellspacing="0">
    <tr>
    <td width="298"> <p>
    <input name="MAX_FILE_SIZE" type="hidden" id="MAX_FILE_SIZE" value="81920">
    </p>
    <input type="file" name="user_photo"></td>
    </tr>
    </table>
    <p>
    <input type="submit" name="Submit" value="Submit">
    </p></td>
    </tr>
    </table>
    </form></td>
    To follow the path:
    Look to the master,
    Follow the master,
    Walk with the master,
    See through the master,
    Become the master.

  3. #3
    Join Date
    Feb 2003
    Location
    Kluang, Johor
    Posts
    2,367
    Rep Power
    249
    mm... have u set the temporary folder?

  4. #4
    Join Date
    Feb 2004
    Location
    Klang Bandar Diraja
    Posts
    160
    Rep Power
    194
    nope, i tought the folder were set automatically... i'll try to fix the temp folder
    To follow the path:
    Look to the master,
    Follow the master,
    Walk with the master,
    See through the master,
    Become the master.

  5. #5
    Join Date
    Feb 2004
    Location
    Klang Bandar Diraja
    Posts
    160
    Rep Power
    194
    i've set the temp folder to C:/phpdev/www/star/profile_photo/ but the image still can't be uploaded.
    To follow the path:
    Look to the master,
    Follow the master,
    Walk with the master,
    See through the master,
    Become the master.

  6. #6
    Join Date
    Feb 2003
    Location
    Kluang, Johor
    Posts
    2,367
    Rep Power
    249
    At your html file to upload file, add the following to the <form>:
    enctype="multipart/form-data"

    So, it will looks like this:
    Code:
    <form name="form1" method="post" action="changephoto.parse.php" enctype="multipart/form-data">
    Last edited by lcf; 06-04-2004 at 04:27 PM.

  7. #7
    Join Date
    Feb 2004
    Location
    Klang Bandar Diraja
    Posts
    160
    Rep Power
    194
    it can't work!still come out with the same error
    To follow the path:
    Look to the master,
    Follow the master,
    Walk with the master,
    See through the master,
    Become the master.

  8. #8
    Join Date
    Feb 2003
    Location
    Kluang, Johor
    Posts
    2,367
    Rep Power
    249
    does simple upload work for you? example in http://my.php.net/features.file-upload

  9. #9
    Join Date
    Feb 2004
    Location
    Klang Bandar Diraja
    Posts
    160
    Rep Power
    194
    wet the menet
    To follow the path:
    Look to the master,
    Follow the master,
    Walk with the master,
    See through the master,
    Become the master.

  10. #10
    Join Date
    Feb 2004
    Location
    Klang Bandar Diraja
    Posts
    160
    Rep Power
    194
    here's the result

    ---------------------------------------------------------------------
    Warning: Unable to create '/var/www/img/logoUH.jpg': No such file or directory in c:\phpdev\www\try oop\upload.parse.php on line 9

    Warning: Unable to move 'C:\WINDOWS\TEMP\php2F.tmp' to '/var/www/img/logoUH.jpg' in c:\phpdev\www\try oop\upload.parse.php on line 9
    Possible file upload attack! Here's some debugging info:
    Array
    (
    [userfile] => Array
    (
    [name] => logoUH.jpg
    [type] => image/pjpeg
    [tmp_name] => C:\WINDOWS\TEMP\php2F.tmp
    [error] => 0
    [size] => 3003
    )

    )
    To follow the path:
    Look to the master,
    Follow the master,
    Walk with the master,
    See through the master,
    Become the master.

  11. #11
    Join Date
    Feb 2004
    Location
    Shah Alam
    Posts
    175
    Rep Power
    193
    your directory structure puzzles me.. are you testing it on windows or linux? cause the path '/var/www...' is linux and C:\Windows\TEMP... is for windows.. ??

  12. #12
    Join Date
    Feb 2004
    Location
    Klang Bandar Diraja
    Posts
    160
    Rep Power
    194
    ohh... i'm on windows platform... okeh .. bertindak mengikut arahan!
    To follow the path:
    Look to the master,
    Follow the master,
    Walk with the master,
    See through the master,
    Become the master.

  13. #13
    Join Date
    Feb 2004
    Location
    Klang Bandar Diraja
    Posts
    160
    Rep Power
    194
    ok.. it works.. then what's wrong with my first code?
    To follow the path:
    Look to the master,
    Follow the master,
    Walk with the master,
    See through the master,
    Become the master.

  14. #14
    Join Date
    Feb 2003
    Location
    Kluang, Johor
    Posts
    2,367
    Rep Power
    249
    So, that is the result you got by running codes from http://my.php.net/features.file-upload ?

    It is working, the error is because of the $uploadir.

    Try to replace:
    PHP Code:
    $uploaddir '/var/www/img/'
    with:
    PHP Code:
    $uploaddir 'C:/phpdev/www/star/profile_photo/'
    Try also:
    PHP Code:
    $uploaddir 'C:\phpdev\www\star\profile_photo\'; 
    *Forgot should be left slash or right slash...

  15. #15
    Join Date
    Feb 2004
    Location
    Klang Bandar Diraja
    Posts
    160
    Rep Power
    194
    this is the info if i use my first code
    -------------------------------------------------------------------
    Array ( [user_photo] => Array ( [name] => lilingang.JPG [type] => image/pjpeg [tmp_name] => C:\WINDOWS\TEMP\php48.tmp [error] => 0 [size] => 57356 ) )
    To follow the path:
    Look to the master,
    Follow the master,
    Walk with the master,
    See through the master,
    Become the master.

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. Rapidmirrors.com File Upload/Mirroring
    By rekomaster in forum Websites Review and Suggestion
    Replies: 3
    Last Post: 10-11-2009, 10:06 AM
  2. upload file
    By aaxeem in forum Website Programming
    Replies: 2
    Last Post: 13-08-2005, 01:53 AM
  3. Upload file
    By safprin in forum Website Programming
    Replies: 5
    Last Post: 24-03-2005, 02:19 AM
  4. Camner Nak Upload file .php
    By akmis in forum Website Programming
    Replies: 21
    Last Post: 12-05-2003, 04:06 PM
  5. upload file via web browser
    By mbek in forum Website Programming
    Replies: 2
    Last Post: 06-04-2003, 11:19 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