Welcome to Geeklog, Anonymous Friday, November 29 2024 @ 05:37 am EST

Geeklog Forums

File Upload Problems


Status: offline

amckay

Forum User
Full Member
Registered: 03/23/02
Posts: 180
Hey folks, I started the day with a upload class that someone had given me, but about 2 hours ago I recalled that GL has a built in upload class. I looked in usersettings.php for an example of how to use it, and here is what I came up with :
Text Formatted Code

                $path = "/home/bodensatz/vdirs/dl/sb";
                $mode = 3;

                $ul     = new upload();
                $ul->setAllowedMimeTypes(array('text/xml','text/txt'));
                if (!$ul->setPath($path)) {
                        print 'File Upload Errors:<BR>' . $ul->printErrors();
                        break;
                }
                if (!isset($upload_filename)) {
                        $display        .= "No filename defined in form<br>";
                        break;
                }
                if ($upload_filename == "") {
                        $display        .= "No filename entered<br>";
                        break;
                }
                $ul->setFileNames($upload_filename);
                $ul->setPerms('0644');
                if (!($ul->uploadFiles()))
                {
                        $display        .= "Error during upload<br>";
                        break;
                }
                if ($ul->areErrors()) {
                        $display        .= "ERRORS<BR>";
                        $ul->printErrors();
                        break;
                }
                $success        = TRUE;

 
Well, it reports success but the file is not in my designated upload path, and so when I then try to open it the program bombs. I verified that I can upload user photos in GL so the GL upload class is working. I also changed the upload path to the same path where the usersettings.php uploads the user photos, and no luck. I'm at my wits end here. What am I doing wrong? thanks, -Alan
 Quote

Status: offline

Tony

Site Admin
Admin
Registered: 12/17/01
Posts: 405
Location:Urbandale, Iowa
Where are you setting $upload_filename? --Tony---The reason people blame things on previous generations is that there's only one other choice.
The reason people blame things on previous generations is that there's only one other choice.
 Quote

Status: offline

amckay

Forum User
Full Member
Registered: 03/23/02
Posts: 180
It was being set in the form and carried through - I did verify it with debuggin statements. I figured out that I was not including the enctype in the form declaration! Doh! Only wasted about 4 hours on that one ... (yes, I do usually spend at least an hour or sometimes more before bothering y'all for help ;-))
 Quote

All times are EST. The time is now 05:37 am.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content