Uploading Files: Definitive answer required. ;-)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • dickiedyce

    #1

    Uploading Files: Definitive answer required. ;-)

    Hi there.

    I've spent the weekend getting ever more frustrated, trying to get an
    upload file function working on a website.

    The site is hosted by a company called oneandone. They're using PHP 4.2.
    3, not in safe mode. I think that the basic problem is the set-up for
    the temp folder, but I don't have access to the .ini settings.

    I'm pretty sure it's possible, because I've got MyPHPAdmin running, and
    it's happily accepting uploaded files (although I can't make head nor
    tail of their code).

    I've read through the manuals online (most of which assume 'it just
    sorta works' or that you have access to the .ini files), and I've tried
    setting the values for upload_tmp_dir using ini_set() but I just can't
    get it to work.

    Here's the code I'm stuck with at the moment...

    file 1: upload.php

    ****

    <?php
    $root = $HTTP_SERVER_VA RS['DOCUMENT_ROOT'];
    ini_set('upload _tmp_
    dir', $root.'tmp');
    ?> <html>
    <head>
    <title>Administ ration - file
    upload</title>
    </head>
    <body>
    <h1>Upload new files</h1>
    <form
    enctype="multip art/form-data" action="upload2 .php" method="post">

    <input type="hidden" name="MAX_FILE_ SIZE" value="1000000" >
    Upload
    this file: <input name="userfile" type="file">
    <input type="submit"
    value="Send File">
    </form>
    </body>
    </html>

    ***

    file 2: upload2.php

    ***


    <?php
    $root = $HTTP_SERVER_VA RS['DOCUMENT_ROOT'];
    ini_set('upload _tmp_
    dir', $root.'tmp');
    ?> <html>
    <head>
    <title>Uploadin g...</title>
    </
    head>
    <body>
    <h1>Uploading file...</h1>
    <?php
    echo 'Document
    root is '.$root."<br />\n";
    echo 'Upload directory: '.ini_get('uplo ad_
    tmp_dir')."<br />\n";
    echo 'Upload directory: '.get_cfg_var(' upload_tmp_dir' )."\n";
    ?>
    </body>
    </html>

    ***

    (I realise that this doesn't actually do any uploading, but I've rolled
    it back as far as I can, as a follower of a walk then run school of
    philosophy, just to get it to tell me where it might deign to upload
    stuff, were it to work ;-) )

    When I execute these two pages, the second page just coughs up a blank
    Upload directory, as if it hasn't been set. Can somebody please point
    me in the right direction?!?!? My desk is starting to get a forehead
    shapped dent in it... I just want to upload some plain text files and a
    few 4k jpgs for goodness sake!

    Aaarrrgh.


    Thanks.

    dd
  • Wil

    #2
    Re: Uploading Files: Definitive answer required. ;-)

    I've been looking at stuff all weekend on googlegroups and I've come
    to the conclusion that on shared servers you can't alter
    upload_tmp_dir using ini_set().

    Comment

    • Pedro Graca

      #3
      Re: Uploading Files: Definitive answer required. ;-)

      Wil wrote:[color=blue]
      > I've been looking at stuff all weekend on googlegroups and I've come
      > to the conclusion that on shared servers you can't alter
      > upload_tmp_dir using ini_set().[/color]

      That's the same conclusion you'd reach by reading ini_set on the manual
      :)

      Sets the value of a configuration option



      The info for "upload_tmp_dir " on the "Changeable " column has
      "PHP_INI_SYSTEM " wich is specified as "Entry can be set in php.ini or
      httpd.conf"
      --
      --= my mail box only accepts =--
      --= Content-Type: text/plain =--
      --= Size below 10001 bytes =--

      Comment

      • jn

        #4
        Re: Uploading Files: Definitive answer required. ;-)

        "Pedro Graca" <hexkid@hotpop. com> wrote in message
        news:c18bi9$1fs ldo$1@ID-203069.news.uni-berlin.de...[color=blue]
        > Wil wrote:[color=green]
        > > I've been looking at stuff all weekend on googlegroups and I've come
        > > to the conclusion that on shared servers you can't alter
        > > upload_tmp_dir using ini_set().[/color]
        >
        > That's the same conclusion you'd reach by reading ini_set on the manual
        > :)
        >
        > http://www.php.net/ini_set
        >
        >
        > The info for "upload_tmp_dir " on the "Changeable " column has
        > "PHP_INI_SYSTEM " wich is specified as "Entry can be set in php.ini or
        > httpd.conf"
        > --
        > --= my mail box only accepts =--
        > --= Content-Type: text/plain =--
        > --= Size below 10001 bytes =--
        >[/color]

        Did you try putting something like this in an .htaccess file?

        php_value upload_tmp_dir /whatever/dir/you/want


        Comment

        • Ian.H

          #5
          Re: Uploading Files: Definitive answer required. ;-)

          On Mon, 02 Feb 2004 14:17:56 +0000, dickiedyce wrote:
          [color=blue]
          > Hi there.
          >
          > I've spent the weekend getting ever more frustrated, trying to get an
          > upload file function working on a website.
          >
          > The site is hosted by a company called oneandone.[/color]


          Oops! ;)

          [color=blue]
          > They're using PHP 4.2.
          > 3, not in safe mode. I think that the basic problem is the set-up for the
          > temp folder, but I don't have access to the .ini settings.[/color]


          I personally think the issue is elsewhere...

          [color=blue]
          > I'm pretty sure it's possible, because I've got MyPHPAdmin running, and
          > it's happily accepting uploaded files (although I can't make head nor tail
          > of their code).[/color]


          I'd say it's uploading fine (assuming your account isn't more restricted
          than wherever phpMA runs).

          [color=blue]
          > I've read through the manuals online (most of which assume 'it just sorta
          > works' or that you have access to the .ini files), and I've tried setting
          > the values for upload_tmp_dir using ini_set() but I just can't get it to
          > work.[/color]


          I have to ask.. why?

          Why are you trying to change the temp upload dir? What's wrong with the
          current one?

          [color=blue]
          > Here's the code I'm stuck with at the moment...[/color]


          [ snip code with no code to process uploaded file ]

          [color=blue]
          > (I realise that this doesn't actually do any uploading, but I've rolled it
          > back as far as I can, as a follower of a walk then run school of
          > philosophy, just to get it to tell me where it might deign to upload
          > stuff, were it to work ;-) )
          >
          > When I execute these two pages, the second page just coughs up a blank
          > Upload directory, as if it hasn't been set. Can somebody please point me
          > in the right direction?!?!? My desk is starting to get a forehead shapped
          > dent in it... I just want to upload some plain text files and a few 4k
          > jpgs for goodness sake!
          >
          > Aaarrrgh.[/color]


          Did you move the uploaded file to your specified dir before the end of the
          script finished executing? You've shown no code that would deal with this.

          When a file is uploaded, it's stored in the $TEMP dir as something like:


          php87Dkdfs9


          You then use something like 'move_upload_fi le()' to put this into
          $YOUR_CHOSEN_PA TH as $YOUR_DEFINED_F ILENAME.

          If you already have this code present but didn't post it here, if you
          could post the section maybe it can be analysed better (I'm not saying
          this _is_ the problem, but without seeing anymore of your code, it's my
          first suspect).



          Regards,

          Ian

          --
          Ian.H
          digiServ Network
          London, UK


          Comment

          Working...