We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22278
    • 8 Posts
    Onno Cleijpool Reply #1, 16 years ago
    Hey all,

    Since you really helped me out with my last post, I have another challenge I can’t get solved.
    In evo, I always used webloginpe. That provided me with the possibility of uploading a user photo.
    I am now using revo and the standard login snippet, but I can’t get an image to load.


    In my document I make a call snippetcall fallowed by a chunk representing my form: [[!UpdateProfile]] [[$updateform]]
    In my form I have used enctype="multipart/form-data" for the form and
    <input type="file" name="photo" class="inputBox" size="35" value="[[+photo]]">

    As soon as the form is being updated, the image name will be stored in the database, but it is not storing any image.
    I probably am missing a large chunk of the concept here.... there is nothing I can find on the web explaining the fundamentals of file upload.

    Hope anybody can help

    Onno
      • 22278
      • 8 Posts
      Onno Cleijpool Reply #2, 16 years ago
      I forgot to tell that I also tried to use postHooks. I did call a snippet like [[!updateProfile? &postHooks=`uploadfile`]]
      The uploadfile snippet then contained the following:

      $userName = $username;
      $targetDir = ’/my full server path/’;
      $errorMessage = ’’;
      $targetFile = $targetDir.$userName.’.jpg’;

      if (isset($_FILES[$photo]) && $_FILES[$photo][’error’] == UPLOAD_ERR_OK)
      {
      if ($_FILES[$photo][’type’] == ’image/jpeg’)
      {
      $result = move_uploaded_file ($_FILES[$photo][’tmp_name’], $targetFile);

      if (!$result) {
      $errorMessage = ’Can not copy file’;
      }
      } else {
      $errorMessage = ’Filetype not correct’;
      }
      } else {
      $errorMessage = ’Upload failed’;
      }

      Also this isn’t working.