We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 16550
    • 23 Posts
    Hello,

    I ’m using a form to download a file into a specific folder.
    For example /picture/xxx.jpg (i m using the time() function into the file name (xxx.jpg) in order that all the files name are different)

    Everything works perfectly
    But here comes the problem:

    I want that the form fill a TV [+tvphoto+] with the path of the uploaded file ([site url]/picture/xxx.jpg...)
    What should i do??

    in the form the code is:
    <label for="file">Photo:</label>
    <input type="hidden" id="file2" name="userphoto" value="[+tvphoto+]" />
    <input id="file" name="file" type="file" value=""/>

    in the php file:
    function photo() {

    if ($_FILES[’file’][’type’] != ’image/jpeg’ && $_FILES[’file’][’type’] != ’image/pjpeg’ && $_FILES[’file’][’type’] != ’image/gif’)
    {
    $erreur = ’Le fichier doit etre au format *.jpeg , *.jpg ou *.gif.’;
    }

    elseif ($_FILES[’fichier’][’size’] > 300000)
    {
    $erreur = ’L\’image doit être inférieure à ’ . $poids_max/1024 . ’Ko.’;
    }

    if(isset($erreur))
    {
    echo ’<b>’ . $erreur . ’L\’image n\’a pas ete chargee, renvoyez un formulaire si vous voulez entrer l\’image ou envoyez uvotre image via la section CONTACT</b>’;
    }
    else
    {
    if ($_FILES[’file’][’type’] == ’image/pjpeg’) { $extention = ’.jpeg’; }
    if ($_FILES[’file’][’type’] == ’image/jpeg’) { $extention = ’.jpg’; }
    if ($_FILES[’file’][’type’] == ’image/gif’) { $extention = ’.gif’; }
    $userImage = time()."-picturet".$extention;
    echo "Upload: " . $_FILES["file"]["name"] . "
    ";
    echo "Type: " . $_FILES["file"]["type"] . "
    ";
    echo "Size: " . ($_FILES["file"]["size"] / 1024) . " Kb
    ";
    echo "Temp file: " . $_FILES["file"]["tmp_name"] . "
    ";

    move_uploaded_file($_FILES["file"]["tmp_name"],
    "/picture/" .$userImage );
    echo "Stored in: " . "/picture/" . $userImage ;
    }
    }