I'm trying to get a site working now I've bought some web hosting options.

I have written a routine for uploading images (only available to myself). The upload_tmp_dir variable is not set and I can't get access to the php.ini file. My ISP suggests using .htaccess to set the variable. So, I've created the file with the following contents.

php_value upload_tmp_dir "/home/jonshaw/public_html/tmp"

I am I missing something.

Any help appreciated.

Thanks.

    Add the trailing slash and make sure the folder exists and has write permissions for yourself
    php_value upload_tmp_dir "/home/jonshaw/public_html/tmp/"

      Louie, thanks for the reply.

      No joy I'm afriad. Added the slash to the end, also put permissions to 777 on the tmp directory.

      phpinfo() reports the variable not set. This is the code that actually does the copy:-

      if (!@copy($the_file, $the_path . "/" . $the_file_name)) {
      return("<B>ERROR</B> Upload Unsuccessful");
      } else {
      return("Upload Successful");
      }

      If I print some variables:-

      print $the_file . " " . $the_path . "/" . $the_file_name;

      I get the following when I try to upload.

      /tmp/phpY14bvN /home/jonshaw/public_html/images/1901-2000/2000/7.JPG

      For some reason, it just won't set the first part (/tmp/????) to the directory in .htaccess.

      I know .htaccess works, as I put garbage in there, and I got a server error.

      I guess I'll have to stick with FTP instead.

        Well by the look of things they do have the tmp dir set up properly. Have yo utried removing the line from the .htaccess file and just running the copy() function like you have. See normally when upload a file it makes temp file that looks something like /tmp/swin3io93 It is up to you to copy the file to a new location.

          I've removed .htaccess and it still doesn't work. I had the routine working fine on my home setup Win98/Apache and also in work winNT/IIS4, but now its on my hosts Linux/Apache I've got no joy.

          Pphinfo reports the variable is not set.
          www.trade4wales.com/test.php

          Thanks anyway - I'll have to stick with FTP - I was just trying to make life a bit easier.

          Jon

            Thats what I am trying to say, it shouldn't be set, your code must be wrong. I don't have that directive set in my php.ini, and I never have a problem unix or NT. Are you absolutely sure that the path is correct and that the dir exists?

              Got it at last - and a stupid mistake - permissions. When I created the directory in FTP, the permissions to the destination directory were 755. So writing in FTP was OK, but not over the web. Set them to 757 and its ok.

              Thanks for the help - much appreciated.

                Write a Reply...