• Login
  • Register
  • Zoek
This Thread
  • Everywhere
  • This Thread
  • This Forum
  • Articles
  • Pages
  • Forum
  • Filebase Entry
  • More Options

ICTscripters

Dé plek voor IT

Dé plek voor IT

Login

Geavanceerde opties
  1. Home
  2. Forum
    1. Alle berichten
    2. Recente activiteiten
  3. ICT Nieuws
  4. Blog
  5. Marktplaats
    1. Werk
    2. Advertenties
    3. Domeinnamen
    4. Websites
    5. Design & lay-outs
    6. Scripts
    7. Overige
  6. Design
  7. Leden
    1. Actieve bezoekers
    2. Team
    3. Leden zoeken
  8. Downloads
  9. Goedkope domeinnamen
  1. Home
  2. Forum
    1. Alle berichten
    2. Recente activiteiten
  3. ICT Nieuws
  4. Blog
  5. Marktplaats
    1. Werk
    2. Advertenties
    3. Domeinnamen
    4. Websites
    5. Design & lay-outs
    6. Scripts
    7. Overige
  6. Design
  7. Leden
    1. Actieve bezoekers
    2. Team
    3. Leden zoeken
  8. Downloads
  9. Goedkope domeinnamen
  1. Home
  2. Forum
    1. Alle berichten
    2. Recente activiteiten
  3. ICT Nieuws
  4. Blog
  5. Marktplaats
    1. Werk
    2. Advertenties
    3. Domeinnamen
    4. Websites
    5. Design & lay-outs
    6. Scripts
    7. Overige
  6. Design
  7. Leden
    1. Actieve bezoekers
    2. Team
    3. Leden zoeken
  8. Downloads
  9. Goedkope domeinnamen
  1. Dé plek voor IT - ICTscripters
  2. Forum
  3. Scripting & programmeren
  4. PHP + SQL

Forum

  • Ictscripters Chat

    AarClay 21 april 2026 om 11:34
  • Het Grote Vibe Code Topic

    Jeroen.G 8 april 2026 om 14:00
  • PWYL source gezocht

    Syntax 25 maart 2026 om 11:44
  • Help testers nodig voor android app Urgent

    Servertjee 20 februari 2026 om 12:07
  • Partner Gezocht om meerdere NFT Collecties op Open Sea te Plaatsen

    Servertjee 20 februari 2026 om 12:06
  • Afspraken systeem met planbeperking

    Jeffrey.Hoekman 20 februari 2026 om 11:52
  • Developer Gezocht

    Servertjee 19 februari 2026 om 17:31
  • Na 15 jaar terug van weggeweest: iCriminals.nl is terug (BETA)!

    Servertjee 18 februari 2026 om 16:57

Marktplaats

  • 370 Nieuwe Domeinnamen April 2026

    shiga 1 mei 2026 om 12:06
  • Snel een website nodig?

    Syntax 10 april 2026 om 12:55
  • Sicarras.com - Moderne Mafia Text-Based RPG

    Syntax 5 april 2026 om 16:22

Uploadscript

  • RDMNL2010
  • 11 oktober 2010 om 17:22
  • Closed
  • RDMNL2010
    webbasing.com
    Berichten
    560
    • 11 oktober 2010 om 17:22
    • #1

    Beste leden van Criminalspoint,

    Ik ben al een tijdje bezig hiermee met een script om MP3 bestanden te uploaden.
    Nu wil het niet lukken... Ik heb in me php.ini me max_file_size al veranderd naar 8M (8mb) dus.
    hieronder het script..

    PHP
    <?php
    if (isset($_POST['submit']))
    {
    //**********************************************************************************************
    
    
    
    
    echo "Please wait while we attempt to upload your file...<br><br>";
    
    
    //**********************************************************************************************
    
    
    
    
    $target_path = "upload/";
    
    
    $flag = 0; // Safety net, if this gets to 1 at any point in the process, we don't upload.
    
    
    $filename = $_FILES['uploadedfile']['name'];
    $filesize = $_FILES['uploadedfile']['size'];
    $mimetype = $_FILES['uploadedfile']['type'];
    
    
    $filename = htmlentities($filename);
    $filesize = htmlentities($filesize);
    $mimetype = htmlentities($mimetype);
    
    
    $target_path = $target_path . basename( $filename );
    
    
    if($filename != ""){
    
    
    echo "Beginning upload process for file named: ".$filename."<br>";
    echo "Filesize: ".$filesize."<br>";
    echo "Type: ".$mimetype."<br><br>";
    
    
    }
    
    
    //First generate a MD5 hash of what the new file name will be
    //Force a MP3 extention on the file we are uploading
    
    
    $hashedfilename = md5($filename);
    $hashedfilename = $hashedfilename.".mp3";
    
    
    //Check for empty file
    if($filename == ""){
    $error = "No File Exists!";
    $flag = $flag + 1;
    
    
    }
    
    
    //Now we check that the file doesn't already exist.
    $existname = "upload/".$hashedfilename;
    
    
    if(file_exists($existname)){
    
    
    if($flag == 0){
    $error = "Your file already exists on the server!  
    Please choose another file to upload or rename the file on your
    computer and try uploading it again!";
    }
    
    
    $flag = $flag + 1;
    }
    
    
    //Whitelisted files - Only allow files with MP3 extention onto server...
    
    
    $whitelist = array(".mp3");
    foreach ($whitelist as $ending) {
    
    
    if(substr($filename, -(strlen($ending))) != $ending) {
     $error = "The file type or extention you are trying to upload is not allowed!  
    You can only upload MP3 files to the server!";
    $flag++;
    }
    }
    
    
    
    
    //Now we check the filesize.  If it is too big or too small then we reject it
    //MP3 files should be at least 1MB and no more than 6.5 MB
    
    
    if($filesize > 6920600){
    //File is too large
    
    
    if($flag == 0){
    $error = "The file you are trying to upload is too large!  
    Your file can be up to 6.5 MB in size only.  
    Please upload a smaller MP3 file or encode your file with a lower bitrate.";
    }
    
    
    $flag = $flag + 1;
    }
    
    
    if($filesize < 1048600){
    //File is too small
    
    
    if($flag == 0){
    $error = "The file you are trying to upload is too small!
    Your file has been marked as suspicious because our system has
    determined that it is too small to be a valid MP3 file.
    Valid MP3 files must be bigger than 1 MB and smaller than 6.5 MB.";
    }
    
    
    $flag = $flag + 1;
    
    
    }
    
    
    //Check the mimetype of the file
    if($mimetype != "audio/x-mp3" and $mimetype != "audio/mpeg"){
    
    
    if($flag == 0){
    $error = "The file you are trying to upload does not contain expected data.
    Are you sure that the file is an MP3?";
    }
    
    
    $flag = $flag + 1;
    }
    
    
    //Check that the file really is an MP3 file by reading the first few characters of the file
    $f = @fopen($_FILES['uploadedfile']['tmp_name'],'r');
    $s = @fread($f,3);
    @fclose($f);
    if($s != "ID3"){
    
    
    if($flag == 0){
    $error = "The file you are attempting to upload does not appear to be a valid MP3 file.";
    }
    
    
    $flag++;
    }
    
    
    
    
    
    
    //All checks are done, actually move the file...
    
    
    if($flag == 0){
    
    
    if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
       
     
        //Change the filename to MD5 hash and FORCE a MP3 extention.
    
    
        if(@file_exists("upload/".$filename)){
    
    
        //Rename the file to an MD5 version
        rename("upload/".$filename, "upload/".$hashedfilename);
    
    
        echo "The file ".  basename( $filename ). "
          has been uploaded.  Your file is <a href='uploads/$hashedfilename'>here</a>.";
       
        }  
        else{
          echo "There was an error uploading the file, please try again!";
        }
    
    
    
    
    } else{
        echo "There was an error uploading the file, please try again!";
    }
    
    
    }
    else {
    echo "File Upload Failed!<br>";
    if($error != ""){
    echo $error;
    }
    }
    }
    ?>
    
    
    <form action="" method="POST" enctype="multipart/form-data">
    Browse file to upload <input type="file" name="filetoupload" id="filetoupload"><br/>
    <input type="submit" name="submit"  value="Upload now">
    </form>
    Toon Meer


    hopelijk dat iemand weet wat hier fout aan is

    map upload is al gechmod naar 755 dus dit is niet het probleem;)

    Webbasing.com

  • Guest, wil je besparen op je domeinnamen? (ad)
  • Superior
    Master
    Berichten
    1.947
    • 11 oktober 2010 om 17:26
    • #2

    Handig als je vermeld wat niet werkt, eventuele fouten ?

  • RDMNL2010
    webbasing.com
    Berichten
    560
    • 11 oktober 2010 om 17:27
    • #3

    Ja sorry vergeten,

    Het probleem is dus dat ie geen fouten aangeeft.. maar ook niks upload. Als ik op de knop Upload now klik dan laad ie (dit duurt een minuutje ofzo) en daarna is het gewoon klaar.. zonder enige melding.

    En als ik dan op me server kijk staat er dus niks in de map upload.

    Webbasing.com

  • Superior
    Master
    Berichten
    1.947
    • 11 oktober 2010 om 17:28
    • #4

    Staat de error report helemaal aan of gedeeltelijk ?

  • RDMNL2010
    webbasing.com
    Berichten
    560
    • 11 oktober 2010 om 17:28
    • #5

    ik heb het overigens ook met dit scriptje geprobeerd
    en deze deed het ook niet.:
    overigens .png afbeeldingen e.d. doet deze wel;)

    PHP
    <?php
    if(isset($_POST['sb'])) {
        $path = "../muziek";
        $file = $_FILES['filetoupload']['name'];
        move_uploaded_file($_FILES['filetoupload']['tmp_name'], "$path/$file");
    }
    ?>
    
    
    
    
    <form action="" method="POST" enctype="multipart/form-data">
    Browse file to upload <input type="file" name="filetoupload" id="filetoupload"><br/>
    <input type="submit" name="sb" id="sb" value="Upload now">
    </form>
    Toon Meer



    Nieuwe reactie samengevoegd met originele reactie op 11.10.10 17:29:01:
    error report staat helemaal aan

    Citaat van Superior

    Staat de error report helemaal aan of gedeeltelijk ?



    Nieuwe reactie samengevoegd met originele reactie op 11.10.10 17:56:12:
    oke probleem is opgelost.. gewoon effe een simpele .htaccess code toegevoegd voor de file size blijkbaar werkt dit beter als het veranderen in me php.ini.

    :slotje:

    Webbasing.com

  • R.Jipping
    ex Administrator
    Ontvangen Reacties
    1
    Berichten
    1.660
    • 11 oktober 2010 om 18:07
    • #6

    op aanvraag gesloten
    :slotje:

    This is ten percent luck, twenty percent skill
    Fifteen percent concentrated power of will
    Five percent pleasure, fifty percent pain
    And a hundred percent reason to remember the name!

Participate now!

Heb je nog geen account? Registreer je nu en word deel van onze community!

Maak een account aan Login

ICT Nieuws

  • Google Cloud is in de problemen (en AWS weet het)

    ICTscripters 14 april 2026 om 12:01
  • Nebius kondigt bouw aan van een van Europa's grootste datacenters

    ICTscripters 31 maart 2026 om 12:03
  • Samsung zal miljoenen verdienen aan Apple iPhone Fold dankzij zijn 12GB RAM

    ICTscripters 11 maart 2026 om 22:42

Blogs

  • Functioneel ontwerp

    Dees 28 december 2014 om 12:38
  • Access Control List implementatie in PHP/MySQL - deel 1/2

    FangorN 28 december 2018 om 12:35
  • Access Control List implementatie in PHP/MySQL - deel 2/2

    FangorN 29 december 2018 om 12:37
  1. Marktplaats
  2. Design
  3. Voorwaarden
  4. Ons team
  5. Leden
  6. Geschiedenis
  7. Regels
  8. Links
  9. Privacy Policy
ICTscripters ©2005 - 2026 , goedkope hosting door DiMoWeb.com, BE0558.915.582
Sponsors: Beste kattenhotel provincie Antwerpen | Beste Zetes eid kaartlezer webshop
Style: Nexus by cls-design
Stylename
Nexus
Manufacturer
cls-design
Licence
Commercial styles
Help
Supportforum
Visit cls-design