SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    gimme the uuuuuuuuuuu duuudie's Avatar
    Join Date
    Feb 2004
    Location
    Switzerland
    Posts
    2,253
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    uploading file problem

    Hi

    I am trying to upload a file on my dev server but it always fail. I am redirect to the manageimages.php page with the error message status=notuploaded.

    Could anyone take a look at this simple script and tell me what is going wrong? Is it the location of the file maybe?

    thanks in advance for your help!

    PHP Code:
    <?php
    require_once ('../includes/global.php');

    if ( 
    eregi('^image/p?jpeg(;.*)?$'$_FILES['uploadedfile']['type'])
      or 
    eregi('^image/gif(;.*)?$'$_FILES['uploadedfile']['type'])
    ) {
       
       
    //pick a file extension
       
    if (eregi('^image/p?jpeg(;.*)?$'$_FILES['uploadedfile']['type']) ) {
       
          
    $extension='.jpg';
       
       }else{
       
          
    $extension='.gif';
       
       }
       
       
    //set the file name
       
    $filename='C:/phpdev/www/uploads/images/' $_POST['filename'] . $extension;
       
       
    //check if the file has been correctly uploaded
       
    if (is_uploaded_file($_FILES['uploadedfile']['tmp_name']) 
       && 
    copy($_FILES['uploadedfile']['tmp_name'], $filename)) {
       
          
    //redirect and display the ok message
          
    header('location:' $url .  'admin/manageimages.php?status=uploaded');       
       
       }
       
          
    //redirect and display the not ok message
          
    header('location:' $url .  'admin/manageimages.php?status=notuploaded');     
       
    }else{
       
       
    //the MIME type wasn't correct --> no .jpg or .gif extensions
       
    header('location:' $url .  'admin/manageimages.php?error=mimetype');

    }
    ?>

  2. #2
    Dinah-Moe Humm mudshark's Avatar
    Join Date
    Dec 2003
    Posts
    1,072
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Since your "redirect and display the not ok message" is unconditional, it will always execute, no?

  3. #3
    gimme the uuuuuuuuuuu duuudie's Avatar
    Join Date
    Feb 2004
    Location
    Switzerland
    Posts
    2,253
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you're right, it might be as simple as that... I will test it asap.

    cheers.



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
  •