Jump to content
class_sick

Web Boleh Bg Org Upload

Recommended Posts

salam.
kwn2,ku nak tanya skit.
mcm mana nak buat satu page dimana page tersebut aku boleh bg org guna utk upload apa2 file ke dlm hosting aku?
dan file tersebut boleh org lain tgk@download.
salah satunya mcm www.yousendit.com

nak google pun ku xtau keyword apa utk page mcm nie.
klo ader source yg boleh ku rujuk,kongsi2 la kat sini ya.

thanks

Share this post


Link to post
Share on other sites
Html side

partial code

CODE
<form method='post' action='proses.php' enctype='multipart/form-data'>
File Utk Diupload:
<input type='file' name='upload_file'>
<input type='submit' value='Upload File'>
</form>



Php side [proses.php]
Aku andaikan semua file disimpan kt dlm folder upload
CODE
<?
$file=$_FILES['upload_file'];

if(!empty($file) && $file['error']==0)
{
    $allowedExtension=array('jpg','gif');
    $extension=substr($filename, strrpos($filename, '.') + 1);
    
    if(in_array($extension,$allowedExtension))
    {
        $locationToSave=dirname(__FILE__).'/upload/'.$file['name'];
        if(!file_exist($locationToSave))
        {
            if(move_uploaded_file($file['tmp_name'],$locationToSave))
            {
                echo 'File telah berjaya diupload';
            }
        }
        else
        {
            echo 'Error:File telahpun wujud';
        }
    }
    else
    {
        echo 'Error:File bukan dr jenis extension yg dibenarkan';
    }
}
else
{
    echo 'Error;Tiada file yg tlh diupload';
}
?>


Ni code utk view file yg dh diupload..lets name it view.php

CODE
<?php
  $dir=dirname(__FILE__).'/upload';
  if($handle=fopen($dir))
  {
      $files=array();
      while(false !==($fileName=readdir($handle)))
      {
          $files[]=$fileName;
      }
  }
  closedir($handle);
  echo 'Senarai file yg tlh diupload';
  foreach($files as $file)
  {
      echo $file;
      echo '<br>';
  }
?>
Edited by slier

Share this post


Link to post
Share on other sites
pilih mana satu nakk... suma free punya script...
CODE
1. http://www.hotscripts.com/search?q=fileupload&cat=All&imageField.x=0&imageField.y=0
2. http://www.refdev.com/free_scripts/PHP/File_Management/File_Upload/
3. http://www.seemysites.net/projFolder/uploader/
4. http://sourceforge.net/projects/uber-uploader
5. http://www.perlservices.net/en/programs/psupload/index.shtml
6. http://script.wareseeker.com/download/flash-file-upload-script.rar/8446

Share this post


Link to post
Share on other sites
QUOTE
website ko tu support php/mysql tak?

guna script yang dah siap tak mau ker?


support .
tu la,ku xtau keywordnyer nak cari kat google. happy.gif

thanks slier.
nnt aku study coding bro bg.
act aku noob psl php nie. happy.gif

thanks mikicun.
nnt aku try satu2.
result dia nnt aku share kat sini.

Share this post


Link to post
Share on other sites
klo aku nak bg seme jenis file boleh upload,boleh ker aku buat mcm nie

CODE
$allowedExtension=array('ALL');


utk dir kat mana nak save file tu,nak kena ubah kat mana?or juz buat satu lg folder `Upload`kat tempat aku letak file proses.php ?

Share this post


Link to post
Share on other sites
QUOTE(class_sick @ Jan 3 2009, 07:17 AM) <{POST_SNAPBACK}>
klo aku nak bg seme jenis file boleh upload,boleh ker aku buat mcm nie

CODE
$allowedExtension=array('ALL');


utk dir kat mana nak save file tu,nak kena ubah kat mana?or juz buat satu lg folder `Upload`kat tempat aku letak file proses.php ?


Nak ubah lokasi, ubah line ni:

CODE
$locationToSave=dirname(__FILE__).'/upload/'.$file['name'];


Ubah upload kepada nama folder kau.

Share this post


Link to post
Share on other sites
QUOTE(class_sick @ Jan 3 2009, 08:21 AM) <{POST_SNAPBACK}>
wokeh.thanks shidi.
dlm kes nie ku nak kena ubah folder upload tu jd 777 ker?
or biar default jer?


Ubah.

Share this post


Link to post
Share on other sites
ku dah buat satu folder `upload` dan set 777 pd folder tu.
mula2 ku try ubah $allowedExtension=array('ALL');
tp xleh gak.
pastu ku tukar balik kpd asal $allowedExtension=array('jpg','gif');
then ku try upload file gif.
dia kuar error Error;Tiada file yg tlh diupload
kat mana silapnyer yer? happy.gif

ku try gune free script yg mikicun bg tu.tp pening skit nak edit.
tu yg nak try yg cara slier bg tu. Edited by class_sick

Share this post


Link to post
Share on other sites
sebelum aku jawab soalan kau. Aku nak tahu, kau ni ada background dalam programming tak? Logical thinking?

Share this post


Link to post
Share on other sites
Patut la pun. Sebab soalan kau tu terlalu asas. Belajar la dulu pasal if statement & logical thinking. Mesti kau boleh buat apa kau nak tu.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...