file upload

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

    file upload

    Hi all,

    I've got some problems uploading files using apache and php on a local
    Windows PC. I'm using the file upload example from the manual, but i
    can't get it to work. I don't get an error message, it's asif nothing
    happens. I can't find the file that should be uploaded on my harddisk.

    Has anyone a working example for file-uploads on a local server with
    the settings for the php.ini file? Any tips?

    Thanx a lot!
    WJ
  • Ken

    #2
    Re: file upload

    "wj" <wzn@jongnederl and.nl> wrote in message
    news:e889feda.0 408231117.317e4 33a@posting.goo gle.com...[color=blue]
    > Hi all,
    >
    > I've got some problems uploading files using apache and php on a local
    > Windows PC. I'm using the file upload example from the manual, but i
    > can't get it to work. I don't get an error message, it's asif nothing
    > happens. I can't find the file that should be uploaded on my harddisk.
    >
    > Has anyone a working example for file-uploads on a local server with
    > the settings for the php.ini file? Any tips?
    >
    > Thanx a lot!
    > WJ[/color]

    Please clarify your question.

    1. Are you uploading the file from one directory on your hard drive to
    another directory on your hard drive?

    or

    2. Are you uploading the file from one directory on your hard drive to a
    directory on the internet server not on your computer?

    Ken


    Comment

    • wj

      #3
      Re: file upload

      "Ken" <kkrolski@wi.rr .com> wrote in message news:<yQxWc.110 35$sO2.10823@tw ister.rdc-kc.rr.com>...[color=blue]
      > "wj" <wzn@jongnederl and.nl> wrote in message
      > news:e889feda.0 408231117.317e4 33a@posting.goo gle.com...[color=green]
      > > Hi all,
      > >
      > > I've got some problems uploading files using apache and php on a local
      > > Windows PC. I'm using the file upload example from the manual, but i
      > > can't get it to work. I don't get an error message, it's asif nothing
      > > happens. I can't find the file that should be uploaded on my harddisk.
      > >
      > > Has anyone a working example for file-uploads on a local server with
      > > the settings for the php.ini file? Any tips?
      > >
      > > Thanx a lot!
      > > WJ[/color]
      >
      > Please clarify your question.
      >
      > 1. Are you uploading the file from one directory on your hard drive to
      > another directory on your hard drive?
      >
      > or
      >
      > 2. Are you uploading the file from one directory on your hard drive to a
      > directory on the internet server not on your computer?
      >
      > Ken[/color]

      The first option. Because i didnt know where to expect the file, I
      searched the whole harddisk, but I cant find the file. I wonder if
      anyone has a working example for a local server, if i can get it to
      work it locally, i hope it wont be too hard to get it to work on the
      internet...

      Greets,
      WJ

      Comment

      • Ken

        #4
        Re: file upload

        This is how I do it. If this does not work, get back to me.

        I have a possible 10 images to store.

        I previously renamed the images with the session_id number and the original
        ext. file_sessionid-name.$i (file name to be moved) Not necessary, just my
        way of tracking the images.

        The hard drive directories:
        $_SESSION['archive_dir_te mp'] = "C:\\Apache
        Group\\Apache2\ \Wisconsin\\upl oadtemp\\"; //original directory
        $_SESSION['archive_dir_mo ve'] = "C:\\Apache
        Group\\Apache2\ \Wisconsin\\upl oaddir\\"; //final directory

        The script:
        $file_id = session_id();
        $_SESSION['picture_name1']=$_FILES['picture1']['name'];

        for ($i=1; $i<=10; $i++) {
        if ($_SESSION['picture_name'. $i] !="")
        { //check to see if a file exists
        $filename = basename($_SESS ION['picture_name'. $i]); //
        remove directory information
        $file=explode(" .",$filename );
        //pick off extension
        $file_sessionid _name=$file_id. "-".$i.".".$f ile[1];
        //session id number.-1.extension
        if(!copy($_FILE S['picture'.$i]['tmp_name'],
        $_SESSION['archive_dir_te mp'].$file_sessioni d_name))
        die("Failed to copy".$_SESSION['picture_name'. $i]."<br><br>") ;
        $_SESSION['file_sessionid _name'.$i] =$file_sessioni d_name;
        }
        }

        Another way:
        @rename($_SESSI ON['archive_dir_te mp'].$filename,
        $_SESSION['archive_dir_mo ve'].$_SESSION['file_sessionid _name'.$i]);
        original directory original file name
        new directory new file name

        // $filename = original file name
        // file_sessionid_ name the new name for the file
        @ eliminates error messages. I suggest you take it out while working on the
        script. After the script works, add it in.

        Hope this helps.
        I am sure there are easier way to accomplish the move. I wanted to track
        the changes in other parts of the program, so I did it this way.
        Ken


        Comment

        Working...