Hi all:

I've been trying to upload files to the server since last night, with no success!

The code is so simple it's embarassing, but it doesn't work!

Can you see where the problem is?

The formpage:

<form enctype="multipart/form-data" action="test.php" method="post" target="_blank">

<input type="hidden" name="MAX_FILE_SIZE" value="1000">

Upload a file: <input type="file" name="userfile" class="ViewForm">

<input type="submit" value="Upload" class="AdminOptions">
</form>

The upload page (upload.php):

$upfile="/images/util/".$userfile_name;
echo $upfile;
echo "<hr>";
copy($userfile,$upfile);
if (!is_uploaded_file($userfile))
{
echo "No Upload !";
}

When I try this code, I get this error:

Warning: Unable to open '' for reading: No such file or directory in /usr/local/etc/httpd/htdocs/test.php on line 16

tx
Kamy

    is that file path there, and does it have the correct permissions to do what you want

      I've just cleaned up the upload code (got rid of the echos) to:

      $upfile="/images/util/".$userfile_name;
      
      copy($userfile,$upfile);
      
      if (!is_uploaded_file($userfile))
      {
      echo "No Upload....";
      }
      
      

      No I'm getting this error:

      Warning: Unable to create '/images/util/hours.txt': No such file or directory in /usr/local/etc/httpd/htdocs/test.php on line 22

      That directory, by the way, exists!

      tx
      Kamy

        post your whole code for us to see, there is something funny going on that you aren't showing, since i see nothing about any .txt's in your code

          As I've stated before, the code is so simple it's embarassing:

          my WHOLE code:

          Form page:

          <html>
          <body>
          <form enctype="multipart/form-data" action="test.php" method="post" target="_blank">
          
          <input type="hidden" name="MAX_FILE_SIZE" value="1000">
          
          Upload a file: <input type="file" name="userfile" class="ViewForm">
          
          <input type="submit" value="Upload" class="AdminOptions">
          </form>
          </body>
          </html>
          
          

          Upload page(upload.php):

          <?
          
          $upfile="/images/util/".$userfile_name;
          echo $upfile;
          echo "<hr>";
          copy($userfile,$upfile);
          if (!is_uploaded_file($userfile))
          {
          echo "No Upload !";
          }
          
          
          ?>
          
           

            Hi, Kamy,

            Are you sure you're not mixing "web"-directories and "physical" directories? What looks like www.yoursite.com/images may, in fact, be located at
            /usr/local/apache/htdocs/images.

            When you're trying to save/copy/delete a file, you have to use "physical" directories.

              Thanx mrskhris,
              I changed the path to:

              /usr/local/etc/httpd/htdocs/images/util/

              I also changes the max-file-size to 10000.

              Now I am able to upload files, but only of type .txt!!

              I need to be able to upload almost any type of files (specially graphics, media...)
              When I try even a small jpg file I getthis error:

              Warning: Unable to open '' for reading: No such file or directory in /usr/local/etc/httpd/htdocs/test.php on line 22

              Any ideas?

                have you tried increasing the size of the max_file_size more, i have heard of this not being too accurate and if you are really close to the size it will die, by the way you can skip the max_file_size and do it this way if you want i use this and it works fine

                <?
                if ($Picture_size < 50000)
                {
                copy($Picture, "./in_photo/" . $logged . "_" . $Picture_name);
                $new = ($logged . "_" . $Picture_name);
                echo "File Uploaded";
                }
                else
                {
                echo "File NOT Uploaded, files must be less than 50 KB";
                }
                ?>
                

                  thanx stolzyboy!

                  It's workin now, so size did matter after all 😃

                    Write a Reply...