[PHP] Anyone knows how to return a link or path of a uploaded file?

Discussion in 'Web Design and Development' started by arular7, Jun 14, 2009.

  1. arular7 macrumors newbie

    Joined:
    May 27, 2009
    #1
    I'm a complete newbie in PHP, and can't find anything concrete to help on this!:confused:

    Here it is:

    - I upload a file, and after that I want php returning the link or path of the file uploaded.

    How and where can I include that part on my upload code?

    This is the code that processes the upload:

    PHP:
    <?php 

    // propriedades do ficheiro 
    $name $_FILES["userfile"]["name"]; 
    $type $_FILES["userfile"]["type"]; 
    $size $_FILES["userfile"]["size"]; 
    $temp $_FILES["userfile"]["tmp_name"]; 
    $error $_FILES["userfile"]["error"]; 

    if (
    $error 0
            die (
    "Ocorreu um erro! Código $error."); 
             
    else 


    if (
    $type == "image/jpg" || $size 500000//condicoes para o ficheiro 

       die(
    "Esse formato não é permitido ou tamanho não permitido"); 


    else 
      { 
    move_uploaded_file($temp,"uploaded/".$name); //move o ficheiro completo para a pasta uploaded 
     
    echo "Upload completo!"
     } 
       
    }   
         
         
    ?>

    Sorry for my english.
    Thanks in advance :apple:
     
  2. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #2
    You should be able to do something like,
    PHP:
    $uploadDest$_SERVER['DOCUMENT_ROOT'] . 'uploaded/' $name;
    This assumes the uploaded folder is in the root directory.
     
  3. arular7 thread starter macrumors newbie

    Joined:
    May 27, 2009
    #3

    Its working, Thanks ;D
     

Share This Page