file uploads in PHP not working

Discussion in 'Software' started by jaythewebguy, Jan 24, 2006.

  1. jaythewebguy

    jaythewebguy Private E-2

    I'm a little stumped right now. The code I have which processes the result of a file upload looks like it should be working. After calling it, I can see the variables from the $_FILES['imagefile'] array as:

    Local file: /var/tmp/phpkJa4ND
    Name: a1101.tif
    Size: 218514
    Type: image/tiff
    Error: 0

    From here though, I can't do anything with this file. Both copy and move_uploaded_file fail. Curiously, if I look in /var/tmp, there isn't anything there, which is a really likely clue as to why copy and move failed. Have I missed something in configuration? Or is something else weird going on? Where did my uploaded file go?:confused:
     
  2. Raits

    Raits Private E-2

    Well, how do they fail? Just a blank screen or any error message given?
     
  3. jaythewebguy

    jaythewebguy Private E-2

    Well, this is running in a test routine so far - nothing live, but the remaining part of the code is:

    $newfile = "./images/delivery_tickets/"+$UpLoadedFile;

    if (copy($UpLoadedFile, $newfile))
    print ("file has been written to storage area...<BR>\n");
    else
    print ("Error writing file...<BR>\n");

    It doesn't seem to matter if I use copy or move_uploaded_file in this if statement. It also hasn't seemed to matter whether I use a relative or absolute path in the $newfile assignment. Maybe I've missed something, but my understanding of both copy and move_uploaded_file is that they return boolean so not much information would be available. Is there more detail on why they're failing? And why can I never see the file in /var/tmp? I don't believe that copy should remove it, but I could see where move would.
     
  4. Raits

    Raits Private E-2

    Does this work?
    PHP:
    $current_dir getcwd();
    $newfile $current_dir."/images/delivery_tickets/"+$UpLoadedFile;

    if (
    copy($UpLoadedFile$newfile))
    print (
    "file has been written to storage area...<BR>\n");
    else
    print (
    "Error writing file...<BR>\n");
     
  5. jaythewebguy

    jaythewebguy Private E-2

    No, it doesn't appear to be working. The resultant output was:

    current_dir = /export/home/accounting
    Moving /var/tmp/phpT_aWND -> /export/home/accounting/images/delivery_tickets/a1101.tif
    Error writing file...

    current_dir is pointing to DocumentRoot on this server. I've also run this before, but I hard coded the absolute path as opposed to setting it in this matter. If this makes any difference, this installation is a development server running on a Sun Ultra 20 with Solaris 9, apache 1.3.34, and php 5.0.5. It is not our production server.
     
  6. Raits

    Raits Private E-2

    Sorry, i have only dealt with virtual servers so i can't help you.
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds