SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2002
    Posts
    84
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    A great band website script but there are problems. Help please:)

    Hi I found this great website script for a bands website where you can post pics, tour dates, lyrics, ect...

    The only problem is that uploading pictures is not working properly

    You can download the script here.
    http://membres.lycos.fr/fluxx/bandwe...andwebsite.zip


    Thanks
    Elfmuse

  2. #2
    blonde.... Sarah's Avatar
    Join Date
    Jul 2001
    Location
    Berkshire, UK
    Posts
    7,442
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Elfmuse,

    Can you please provide more information, for example,

    what actual doesn't work? Do you get an error message, if yes what is the error message say, highlight and paste that part of the script here.

    The more ifnormation that you can provide the quicker you should get a response.

    Thank you

    Sarah
    Regular user

  3. #3
    SitePoint Enthusiast
    Join Date
    Jul 2002
    Posts
    84
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's when I try to upload a picture under the admin functions. I'm uploading a *.jpg but get this error message when I click to upload

    only jpg files allowed
    naam is not a jpg but MIME-type

    Thanks

  4. #4
    blonde.... Sarah's Avatar
    Join Date
    Jul 2001
    Location
    Berkshire, UK
    Posts
    7,442
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    in the php text search fiule the lines which ahve the "only jpg images allowed" and then print out that line of code here (wiht a few lines above and below) as that will show you waht they ahve used to determine if its a jpg file or not.

    Sarah
    Regular user

  5. #5
    SitePoint Enthusiast
    Join Date
    Jul 2002
    Posts
    84
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    code around the error message

    if($extensie=="pjpeg"){
    $extensie="jpg";
    }
    if($extensie=="jpeg"){
    $extensie="jpg";
    }


    if ($size > $maxsize) {
    echo "Foto cant be larger then 100 Kb!<br>";
    echo "$naam = $grootte kb.";

    }

    elseif ($extensie!="jpg"){
    echo "only jpg files allowed!<br>";
    echo "$naam is not a jpg but MIME-type: $ext.";

    }

    else //upload plaatje
    {


    if($plaatje<>"none") {
    if(!copy($plaatje,"$dir/$naam")) {

    echo"<font color='red'><b>Error/b> not uploaded.<br></font>\n";
    echo"try again.";
    }

    else {
    echo "<b>Picture is uploaded.</b><br>\n";
    echo "$naam<br>size: $grootte kb";
    }
    }
    break;
    } }

    break;
    case links:

  6. #6
    blonde.... Sarah's Avatar
    Join Date
    Jul 2001
    Location
    Berkshire, UK
    Posts
    7,442
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Hmm okay well it seems that it doesn't recognise what the type is, try adding in this line above your section of code
    you posted.

    PHP Code:
    echo "the type of file is $extensie
    before this part
    PHP Code:
    if($extensie=="pjpeg"){ 
    $extensie="jpg"

    if(
    $extensie=="jpeg"){ 
    $extensie="jpg"

    That will echo out what the script thinks your image is...

    I am assuming the $extensie is taken from the form you use to load up the script?

    Might be worth pasteing that part of the code also

    Sarah
    Regular user

  7. #7
    SitePoint Enthusiast
    Join Date
    Jul 2002
    Posts
    84
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmmmmm thanks for pointing me to look at that file I noticed that it doesn't have a *php extention on it. I have a feeling that this is the problem but can't test since I'm at work.

    Thanks for the help, I'll reply later tonight when I get home

  8. #8
    SitePoint Enthusiast
    Join Date
    Jul 2002
    Posts
    84
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think the form script was just right above it

    break;
    case pictures:
    $dir=images; // relatieve pad tov dit script
    $maxsize=102400; // maximale grootte vh bestand (1024 x 100 bit)


    // de code


    if (!$func) {

    $func = "een";
    }

    switch ($func) {

    case een:
    //formulier voor upload

    echo "<form method=\"post\" enctype=\"multipart/form-data\" action=admin.php?section=pictures>";
    echo "Give Path<br><br><input type=\"file\" name=\"plaatje\" size=\"30\">";
    echo "<input type=\"hidden\" name=\"func\" value=\"twee\">";
    echo " <input type=\"submit\" value=\"Upload\">";
    break;

    case twee:

    $naam=$plaatje_name; //de naam vh plaatje
    $ext=$plaatje_type; //het file of MIME-type
    $length=strlen($ext); //lengte vh type (bv image/pjpeg)
    $pos=strpos($ext,"/")+1; //de positie in het type na de slash
    $extensie=substr($ext,$pos,$length); //dit is de extensie (bv pjpeg)
    $size = $plaatje_size; //grootte vh plaatje
    $grootte = ($size / 1000); // grootte in kb


    // deze MIME types worden goedgekeurd: jpg, jpeg, pjpeg
    // dit zijn nml allen jpg files.
    // dus nu passen we dit eerst aan.

    if($extensie=="pjpeg"){
    $extensie="jpg";
    }
    if($extensie=="jpeg"){
    $extensie="jpg";
    }


    if ($size > $maxsize) {
    echo "Foto cant be larger then 100 Kb!<br>";
    echo "$naam = $grootte kb.";

    }

    elseif ($extensie!="jpg"){
    echo "only jpg files allowed!<br>";
    echo "$naam is not a jpg but MIME-type: $ext.";
    }

    else //upload plaatje
    {


    if($plaatje<>"none") {
    if(!copy($plaatje,"$dir/$naam")) {

    echo"<font color='red'><b>Error/b> not uploaded.<br></font>\n";
    echo"try again.";
    }

    else {
    echo "<b>Picture is uploaded.</b><br>\n";
    echo "$naam<br>size: $grootte kb";
    }
    }
    break;
    } }

    break;
    case links:
    if ($submit){
    $query = "INSERT INTO links (url,name) VALUES ('$url','$name')";
    mysql_query($query) or die ("query failed");
    echo"The link has been posted!<br><a href=admin.php?section=links>Back</a><br>";

  9. #9
    blonde.... Sarah's Avatar
    Join Date
    Jul 2001
    Location
    Berkshire, UK
    Posts
    7,442
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I 'think' that if you replaced the $extensie with $ext you might get it to work. and used this image/pjpeg and image/jpeg rather than just pjpeg and jpeg?

    When you can try to echo out the results you might see why but basically it looks to have an issue with your type..

    Best wait until you can each it out before going any further no error (other than not using globals) that I can see

    Sarah
    Regular user

  10. #10
    blonde.... Sarah's Avatar
    Join Date
    Jul 2001
    Location
    Berkshire, UK
    Posts
    7,442
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    actually thinking about it further (brain in gear) it could be that your machine is on the newer version of PHP and this script isn't.

    Therefore this part should read something like this:
    PHP Code:
    $naam=$_FILES['plaatje']['name']; //de naam vh plaatje 
    $ext=$_FILES['plaatje']['type']; //het file of MIME-type 
    $length=strlen($ext); //lengte vh type (bv image/pjpeg) 
    $pos=strpos($ext,"/")+1//de positie in het type na de slash 
    $extensie=substr($ext,$pos,$length); //dit is de extensie (bv pjpeg) 
    $size $_FILES['plaatje']['size']; //grootte vh plaatje 
    $grootte = ($size 1000); // grootte in kb 
    so try that change before you try anything else.. sorry should have twigged on that one sooner

    Sarah
    Regular user


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •