النتائج 1 إلى 6 من 6

الموضوع: سكريبت حلو لكن ناقص شوية

  1. #1
    عضو سوبر نشيط
    تاريخ التسجيل
    Feb 2003
    المشاركات
    695

    سكريبت حلو لكن ناقص شوية



    يا اخوان هذا السكريبت حلو ويرفع ملفات للدومين الجديد لكنه ما يقبل غير الصور لكن انا اريد يرفع ملفات اخرى غير الصور.
    لا تبخلوا بمساعدتنا الله يساعدكم دوما

    <?php
    // specify the directory where the uploaded file should end up
    $path = 'upload/' ;
    // specify the filetypes allowed
    $allowed = array('image/gif','image/pjpeg','image/jpeg','image/png');
    // specify the max filesize in bytes
    $max_size = 3000000;
    if(isset($HTTP_POST_FILES['userfile']))
    {
    if(is_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name']))
    {
    if($HTTP_POST_FILES['userfile']['size'] < $max_size)
    {
    if(in_array($HTTP_POST_FILES['userfile']['type'],$allowed))
    {
    if(!file_exists($path . $HTTP_POST_FILES['userfile']['name']))
    {
    if(@rename($HTTP_POST_FILES['userfile']['tmp_name'],$path.$HTTP_POST_FILES['userfile']['name']))
    {
    $html_output = 'file1 sucessful!<br>';
    $html_output .= 'File Name: '.$HTTP_POST_FILES['userfile']['name'].'<br>';
    $html_output .= 'File Size: '.$HTTP_POST_FILES['userfile']['size'].' bytes<br>';
    $html_output .= 'File Type: '.$HTTP_POST_FILES['userfile']['type'].'<br>';
    $image = $HTTP_POST_FILES['userfile']['name'] ;
    }else{
    $html_output = 'file1 failed!<br>';
    if(!is_writeable($path))
    {
    $html_output = 'The Directory "'.$path.'" must be writeable!<br>';
    }else{
    $html_output = 'an unknown error ocurred.<br>';
    }
    }
    }else{
    $html_output = 'The file already exists<br>';
    }
    }else{
    $html_output = 'Wrong file type<br>';
    }
    }else{
    $html_output = 'The file is too big<br>';
    }
    }
    }else{
    $html_output = '<form method="post" enctype="multipart/form-data" action="'.$_SERVER['PHP_SELF'].'">';
    $html_output .= '<input type="file" name="userfile">';
    $html_output .= '<input type="submit" value=" SEND ">';
    $html_output .= '</form>';
    }
    echo '<html><head><title>file1file1er</title></head><body>';
    echo $html_output;
    echo '</body></html>';
    ?>





    __________________
    لا خير في كاتـــــــــ العلم ــــــــم.


  2. #2
    عضو نشيط
    تاريخ التسجيل
    Nov 2005
    المشاركات
    104


    حدد ايش الملفات الي تريد تضيفها






  3. #3
    عضو فعال جدا
    تاريخ التسجيل
    Apr 2002
    المشاركات
    2,046


    السلام عليكم ورحمة الله وبركاته...

    قمت بتعديل الكود حتى يسمح لكافة الأنواع بالرفع
    ولكنه غير آمن من الناحية العملية
    فيجب استخدام معه ملف htaccess. لمنع رفع ملفات ضارة بالموقع

    كود PHP:
    <?php 
    // specify the directory where the uploaded file should end up 
    $path 'upload/' 
    // specify the max filesize in bytes 
    $max_size 3000000
    if(isset(
    $HTTP_POST_FILES['userfile'])) 

    if(
    is_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name'])) 

    if(
    $HTTP_POST_FILES['userfile']['size'] < $max_size

    if(!
    file_exists($path $HTTP_POST_FILES['userfile']['name'])) 

    if(@
    rename($HTTP_POST_FILES['userfile']['tmp_name'],$path.$HTTP_POST_FILES['userfile']['name'])) 

    $html_output 'file1 sucessful!<br>'
    $html_output .= 'File Name: '.$HTTP_POST_FILES['userfile']['name'].'<br>'
    $html_output .= 'File Size: '.$HTTP_POST_FILES['userfile']['size'].' bytes<br>'
    $html_output .= 'File Type: '.$HTTP_POST_FILES['userfile']['type'].'<br>'
    $image $HTTP_POST_FILES['userfile']['name'] ; 
    }else{ 
    $html_output 'file1 failed!<br>'
    if(!
    is_writeable($path)) 

    $html_output 'The Directory "'.$path.'" must be writeable!<br>'
    }else{ 
    $html_output 'an unknown error ocurred.<br>'


    }else{ 
    $html_output 'The file already exists<br>'

    }else{ 
    $html_output 'The file is too big<br>'


    }else{ 
    $html_output '<form method="post" enctype="multipart/form-data" action="'.$_SERVER['PHP_SELF'].'">'
    $html_output .= '<input type="file" name="userfile">'
    $html_output .= '<input type="submit" value=" SEND ">'
    $html_output .= '</form>'

    echo 
    '<html><head><title>file1file1er</title></head><body>'
    echo 
    $html_output
    echo 
    '</body></html>'
    ?>
    تحياتي لك





    __________________
    مدونتي

  4. #4
    عضو سوبر نشيط
    تاريخ التسجيل
    Feb 2003
    المشاركات
    695


    مشكورين والله يوفقكم الف توفيق

    وياريت اذا في امكانية للامان مثلا واحد يحدد فقط ملفات معينة مثل rm , ram, mp3, avi

    وشكرا





    __________________
    لا خير في كاتـــــــــ العلم ــــــــم.

  5. #5
    عضو فعال جدا
    تاريخ التسجيل
    Apr 2002
    المشاركات
    2,046


    السلام عليكم ورحمة الله وبركاته...

    ده نفس الكود ولكن مع تمكين أنواع الملفات rm, ram, avi, mp3
    بالاضافة الى أنواع ملفات الصور

    كود PHP:
    <?php 
    // specify the directory where the uploaded file should end up 
    $path 'upload/' 
    // specify the filetypes allowed 
    $allowed = array('image/gif','image/pjpeg','image/jpeg','image/png''application/vnd.rn-realmedia','audio/x-pn-realaudio','audio/x-pn-realaudio','application/x-troff-msvideo''video/avi''video/msvideo''video/x-msvideo''audio/mpeg3''audio/x-mpeg-3''video/mpeg''video/x-mpeg'); 
    // specify the max filesize in bytes 
    $max_size 3000000
    if(isset(
    $HTTP_POST_FILES['userfile'])) 

    if(
    is_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name'])) 

    if(
    $HTTP_POST_FILES['userfile']['size'] < $max_size

    if(
    in_array($HTTP_POST_FILES['userfile']['type'],$allowed)) 

    if(!
    file_exists($path $HTTP_POST_FILES['userfile']['name'])) 

    if(@
    rename($HTTP_POST_FILES['userfile']['tmp_name'],$path.$HTTP_POST_FILES['userfile']['name'])) 

    $html_output 'file1 sucessful!<br>'
    $html_output .= 'File Name: '.$HTTP_POST_FILES['userfile']['name'].'<br>'
    $html_output .= 'File Size: '.$HTTP_POST_FILES['userfile']['size'].' bytes<br>'
    $html_output .= 'File Type: '.$HTTP_POST_FILES['userfile']['type'].'<br>'
    $image $HTTP_POST_FILES['userfile']['name'] ; 
    }else{ 
    $html_output 'file1 failed!<br>'
    if(!
    is_writeable($path)) 

    $html_output 'The Directory "'.$path.'" must be writeable!<br>'
    }else{ 
    $html_output 'an unknown error ocurred.<br>'


    }else{ 
    $html_output 'The file already exists<br>'

    }else{ 
    $html_output 'Wrong file type<br>'

    }else{ 
    $html_output 'The file is too big<br>'


    }else{ 
    $html_output '<form method="post" enctype="multipart/form-data" action="'.$_SERVER['PHP_SELF'].'">'
    $html_output .= '<input type="file" name="userfile">'
    $html_output .= '<input type="submit" value=" SEND ">'
    $html_output .= '</form>'

    echo 
    '<html><head><title>file1file1er</title></head><body>'
    echo 
    $html_output
    echo 
    '</body></html>'
    ?>
    تحياتي لك





    __________________
    مدونتي

  6. #6
    عضو سوبر نشيط
    تاريخ التسجيل
    Feb 2003
    المشاركات
    695


    يا أخ mahmoud009

    والله ما ادري شلون اشكرك
    بس الله اعلم مافي القلوب
    مليون شكر وبس





    __________________
    لا خير في كاتـــــــــ العلم ــــــــم.





ضوابط المشاركة

  • لا تستطيع إضافة مواضيع جديدة
  • لا تستطيع الرد على المواضيع
  • لا تستطيع إرفاق ملفات
  • لا تستطيع تعديل مشاركاتك
  •  

أضف موقعك هنا| اخبار السيارات | حراج | شقق للايجار في الكويت | بيوت للبيع في الكويت | دليل الكويت العقاري | مقروء | شركة كشف تسربات المياه | شركة عزل اسطح بالرياض | عزل فوم بالرياض| عزل اسطح بالرياض | كشف تسربات المياة بالرياض | شركة عزل اسطح بالرياض