Go Back   Webmaster Malaysia Forum » Website Design & Development » Website Programming

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-01-2005, 08:24 AM
safprin's Avatar
Novice Webmaster
 
Join Date: Feb 2004
Location: depan pc
Posts: 99
Rep Power: 0
safprin is an unknown quantity at this point
Upload file

halo...

meh sini pakarČ php...
sy ade download upload script dan berjaya la upload file kat server... tp la yg buat sy musykil la kan... dier leh set limit saiz... so sy set ler...

then... mmg jalan rr script tu...
tp yg nak sy citekan kat sini sy set la limit saiz tu melebihi 2mb
cth la 5mb...

sy upload mp3 2mb kebawah semua lepas... tp bila dah lebih 2mb je dia error x leh upload... padahal saiz limit dia 5mb...

kenapa yer? mmg server set ke?

scriptnyer seperti berikut...

PHP Code:
# header & title of this file
$title "File Upload Manager";

# individual file size limit - in bytes (102400 bytes = 100KB)
$file_size_ind "102400";

# the upload store directory (chmod 777)
$dir_store"store";

# the images directory
$dir_img"img";

# the style-sheet file to use (located in the "img" directory, excluding .css)
$style "style-def";

# the file type extensions allowed to be uploaded
$file_ext_allow = array("gif","jpg","jpeg","png","txt","nfo","doc","rtf","htm","dmg","zip","rar","gz","exe");

# option to display the file list
# to enable/disable, enter '1' to ENABLE or '0' to DISABLE (without quotes)
$file_list_allow 1;

# option to allow file deletion
# to enable/disable, enter '1' to ENABLE or '0' to DISABLE (without quotes)
$file_del_allow 1;

# option to password-protect this script [-part1]
# to enable/disable, enter '1' to ENABLE or '0' to DISABLE (without quotes)
$auth_ReqPass 0;

# option to password-protect this script [-part2]
# if "$auth_ReqPass" is enabled you must set the username and password
$auth_usern "username";
$auth_passw "password";

################ end of configurations ###############


# DO NOT ALTER OR EDIT BELOW THIS LINE UNLESS YOU ARE AN ADVANCED PHP PROGRAMMER

?> 
besambung
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 03-01-2005, 08:26 AM
safprin's Avatar
Novice Webmaster
 
Join Date: Feb 2004
Location: depan pc
Posts: 99
Rep Power: 0
safprin is an unknown quantity at this point
PHP Code:
if (@phpversion() < '4.1.0') {
    $_FILE = $HTTP_POST_FILES;
    $_GET = $HTTP_GET_VARS;
    $_POST = $HTTP_POST_VARS;
}
clearstatcache();
error_reporting(E_ALL & ~E_NOTICE);
$fum_vers = "1.3"; # do not edit this line, the script will not work!!!
$fum_info_full = "File Upload Manager v$fum_vers";

function authDo($auth_userToCheck, $auth_passToCheck) 
{
    global $auth_usern, $auth_passw;
    $auth_encodedPass = md5($auth_passw);
    
    if ($auth_userToCheck == $auth_usern && $auth_passToCheck == $auth_encodedPass) {
    $auth_check = TRUE;
    } else {
    $auth_check = FALSE;
    } 
    return $auth_check;
    }
    
    if (isset($logout)) {
    setcookie ('fum_user', "",time()-3600); 
    setcookie ('fum_pass', "",time()-3600);
    }
        
    if (isset($login)) {
    $auth_password_en = md5($auth_formPass); 
    $auth_username_en = $auth_formUser;

    if (authDo($auth_username_en, $auth_password_en)) { 
    setcookie ('fum_user', $auth_username_en,time()+3600); 
    setcookie ('fum_pass', $auth_password_en,time()+3600); 
    $auth_msg = "<b>Authentication successful!</b> The cookies have been set.<br><br>".
    $auth_msg . "Your password (MD5 encrypted) is: $auth_password_en";
    } else { 
    $auth_msg = "<b>Authentication error!</b>";
    }
}

if (($_GET[act]=="dl")&&$_GET[file]) 
{
    if ($auth_ReqPass != 1 || ($auth_ReqPass == 1 && isset($fum_user) && !isset($logout))) { 
    if ($auth_ReqPass != 1 || ($auth_ReqPass == 1 && authDo($fum_user, $fum_pass))) {

    $value_de=base64_decode($_GET[file]);
    $dl_full=$dir_store."/".$value_de;
    $dl_name=$value_de;

    if (!file_exists($dl_full))
    { 
    echo"ERROR: Cannot download file, it does not exist.<br>»<a href=\"$_SERVER[PHP_SELF]\">back</a>";  
    exit();
    } 
    
    header("Content-Type: application/octet-stream");
    header("Content-Disposition: attachment; filename=$dl_name");
    header("Content-Length: ".filesize($dl_full));
    header("Accept-Ranges: bytes");
    header("Pragma: no-cache");
    header("Expires: 0");
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    header("Content-transfer-encoding: binary");
            
    @readfile($dl_full);
    
    exit();

    }
    }
}

function getlast($toget)
{
    $pos=strrpos($toget,".");
    $lastext=substr($toget,$pos+1);

    return $lastext;
}

function replace($o)
{
    $o=str_replace("/","",$o);
    $o=str_replace("\\","",$o);
    $o=str_replace(":","",$o);
    $o=str_replace("*","",$o);
    $o=str_replace("?","",$o);
    $o=str_replace("<","",$o);
    $o=str_replace(">","",$o);
    $o=str_replace("\"","",$o);
    $o=str_replace("|","",$o);
    
    return $o;
}

?>
<!-- <?=$fum_info_full?> -->
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 03-01-2005, 08:27 AM
safprin's Avatar
Novice Webmaster
 
Join Date: Feb 2004
Location: depan pc
Posts: 99
Rep Power: 0
safprin is an unknown quantity at this point
PHP Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title><? echo ($title) ? ($title) : ("File Upload Manager"); ?></title>
<link rel="stylesheet" href="<?=$dir_img?>/<?=$style?>.css" type="text/css">
<?
    
if ($auth_ReqPass == 1
    { 
        if (isset(
$login) || isset($logout)) {
            echo(
"<meta http-equiv='refresh' content='2;url=$_SERVER[PHP_SELF]'>");
        }
    }
?>
</head>
<body bgcolor="#F7F7F7"><br><br>
<center>
<?    
    
if ($auth_ReqPass != || ($auth_ReqPass == && isset($fum_user) && !isset($logout))) { 
    if (
$auth_ReqPass != || ($auth_ReqPass == && authDo($fum_user$fum_pass))) {
?>
<table width="560" cellspacing="0" cellpadding="0" border="0">
  <tr>
    <td><font size="3"><b><i><? echo ($title) ? ($title) : ("File Upload Manager"); ?></i></b></font>&nbsp;<font style="text-decoration: bold; font-size: 9px;">v<?=$fum_vers?></font>&nbsp;
<? 
    
#--Please do not remove my link/copyright as it is unfair and a breach of the license--#
    
echo"<a href=\"http://www.mtnpeak.net\" style=\"text-decoration: none; color: #C0C0C0; font-size: 9px; cursor: default\";>&copy; thepeak</a>"
?>
    </td>
   </tr>
</table>
<?
    
if (!eregi("777",decoct(fileperms($dir_store))))
    {
        echo
"<br><br><b><h4><font color=\"FF0000\">ERROR: cannot access the upload store file directory. please chmod the \"$dir_store\" directory with value 0777 (xrw-xrw-xrw)!</h4></font></b><br>»<a href=\"$_SERVER[PHP_SELF]\">refresh</a>";
    }
    else
    {
        if (!
$_FILES[fileupload])
        {
?>
<table width="560" cellspacing="0" cellpadding="0" border="0" class="table_decoration" style="padding-top:5px;padding-left=5px;padding-bottom:5px;padding-right:5px">
  <form method="post" enctype="multipart/form-data">
  <tr>
    <td>file:</td><td><input type="file" name="fileupload" class="textfield" size="30"></td>
  </tr>
  <tr>
    <td>rename to:</td><td><input type="text" name="rename" class="textfield" size="46"></td>
  </tr>
  <tr>
    <td>file types allowed:</td><td>
    <?
    
for($i=0;$i<count($file_ext_allow);$i++)
    {
        if ((
$i<>count($file_ext_allow)-1))$commas=", ";else $commas="";
        list(
$key,$value)=each($file_ext_allow);
        echo 
$value.$commas;
    }
    
?>
    </td>
  </tr>
  <tr>
    <td>file size limit:</td>
    <td>
        <b><?
            
if ($file_size_ind >= 1048576
            {
                
$file_size_ind_rnd round(($file_size_ind/1024000),3) . " MB";
            } 
            elseif (
$file_size_ind >= 1024
            {    
                
$file_size_ind_rnd round(($file_size_ind/1024),2) . " KB";
            } 
            elseif (
$file_size_ind >= 0
            {
                
$file_size_ind_rnd $file_size_ind " bytes";
            } 
            else 
            {
                
$file_size_ind_rnd "0 bytes";
            }
            
            echo 
"$file_size_ind_rnd";
        
?></b>
    </td>
  </tr>
  <tr>
    <td colspan="2"><input type="submit" value="upload" class="button">&nbsp;<input type="reset" value="clear" class="button"></td>
  </tr>
  </form>
</table>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 08-01-2005, 08:39 PM
safprin's Avatar
Novice Webmaster
 
Join Date: Feb 2004
Location: depan pc
Posts: 99
Rep Power: 0
safprin is an unknown quantity at this point
xpe rr padam je mesej neh...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 24-03-2005, 12:58 AM
Novice Webmaster
 
Join Date: Aug 2003
Location: sabah
Posts: 23
Rep Power: 0
smartki is on a distinguished road
Send a message via Yahoo to smartki
i know this script!!

saya dah try script ni..boleh run smooth takdak masalah tukar je

# individual file size limit - in bytes (102400 bytes = 100KB)
$file_size_ind = "102400";

jadik

# individual file size limit - in bytes (102400 bytes = 100KB)
$file_size_ind = "102400000"; --- 10 meg

ok jer..
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 24-03-2005, 02:19 AM
Mesra's Avatar
Novice Webmaster
 
Join Date: Jan 2005
Location: Malaysia
Posts: 51
Rep Power: 49
Mesra is on a distinguished road
Dah check ko punyer php upload_max_filesize ker? Biasanya default 2M jer. Cuba refer dengan hosting provider ko.
__________________
Traveler

Last edited by Mesra; 26-04-2005 at 01:43 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
upload file aaxeem Website Programming 2 13-08-2005 01:53 AM
upload file to mysql table... ginger_nur Website Programming 1 07-06-2005 12:27 PM
upload file nurulmajdi Website Programming 21 15-04-2004 02:01 PM
Camner Nak Upload file .php akmis Website Programming 21 12-05-2003 04:06 PM
upload file via web browser mbek Website Programming 2 06-04-2003 11:19 PM


All times are GMT +8. The time now is 02:00 PM. Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0 vBulletin skin by ForumMonkeys.com.


WebmasterMalaysia.com is Proudly Hosted by Exabytes Semi Dedicated Server.

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