A Digital Age Deserves A Digital Leader

Weavers' PHP Upload Script.

Weavers' PHP Upload Script.

Postby Dalsim » Fri May 14, 2004 5:04 am

Ok Weaver, I got your upload script working to a certain extent. I can now upload via it but the problem being is that I can not access anything that I have uploaded via it, I keep getting a 401 error. I tryed another script thinking that iti could have been a problem with the authentication on that subdir but the other script worked.

I would like to use yours' due to the features that you have in it.

Any idea what the problem is?
"Life is merely a fraction of a second. An infinitely small amount of time to fulfill our desires, our dreams, our passions." Paul Gauguin (1848 - 1904)
AEST
PROfessional Member
Posts: 1119
Joined: Sun Jun 15, 2003 7:07 am
Location: Queensland, Australia

Re: Weavers' PHP Upload Script.

Postby Weaver » Fri May 14, 2004 6:03 am

dalsim wrote:Ok Weaver, I got your upload script working to a certain extent. I can now upload via it but the problem being is that I can not access anything that I have uploaded via it, I keep getting a 401 error. I tryed another script thinking that iti could have been a problem with the authentication on that subdir but the other script worked.

I would like to use yours' due to the features that you have in it.

Any idea what the problem is?


For those of you not familiar with what he is referring to, you can access the upload script here .

Jeff, what platform are you running the script on? I haven't tested it using Apache on Windows. I have tested it using recent versions of Apache and PHP on Linux. Windows based PHP has been known to cause issues with many scripts.

So you have the $UPLOAD_DIR set to a place inside your web docuemnt tree? After the files are uploaded, they are placed in a directory that is accessible on the web, correct? If so, I wouldn't recommend it. But if you really need to, I suppose.

Like I mentioned above, I am going to need to know what OS, what webserver, what version of PHP, etc. Do you have safe_mode enabled, how about register_globals ? Also post the specific error that you are receiving. You may want to try using a different browser and see if that solves your problem, just a thought.

If all else fails, I can take a look at it on your server.

-Weaver
Public Keys

The primary purpose of the DATA statement is to give names to constants; instead of referring to pi as 3.141592653589793 at every appearance, the variable PI can be given that value with a DATA statement and used instead of the longer form of the constant. This also simplifies modifying the program, should the value of pi change.
-- FORTRAN manual for Xerox Computers
PROfessional Member
User avatar
Posts: 1967
Joined: Wed Jun 19, 2002 12:05 am
Location: /home/weaver/

Postby Dalsim » Fri May 14, 2004 8:57 am

I am running version 1.3.29 of apache. Here is the info for the version of php 4.3.4 I am running http://www.self-solutions.net/phpinfo.php

I am using RedHat Enterprise 3 Kernel version 2.6.3-sxeon-3w

This is the setup for the script http://www.self-solutions.net/upload.txt

I appreciate you helping me with this.
"Life is merely a fraction of a second. An infinitely small amount of time to fulfill our desires, our dreams, our passions." Paul Gauguin (1848 - 1904)
AEST
PROfessional Member
Posts: 1119
Joined: Sun Jun 15, 2003 7:07 am
Location: Queensland, Australia

Postby Weaver » Fri May 14, 2004 3:48 pm

Alright Jeff, I have a couple of ideas.

First off, why are you running PHP in CGI mode and not as a module? That might have something to do with it, might not. I have a few other ideas below.

Your post_max_size is set to 55 MiB, that's fine (it's actually quite large).

Your upload_max_filesize is set to 2 MiB. As such, the largest file you will be able to upload is 2 MiB even though post_max_size is 55 MiB.

Your max_input_time is set to -1, this means that it pulls its value from max_execution_time (and not unlimited as many people think).

Your max_execution time is set to 30 [seconds].

With your current configuration the largest file you can upload is 2 MiB in size and you have to do it in 30 seconds or less (including any execution time).

If you are trying to upload a file larger than 2 MiB, you will have problems. If it takes you longer than 30 seconds to upload, you will have problems. These are all options that you can change in your php.ini file.

In the next version of the script ( 0.3 ) I am going to include some functionality to check to make sure these values are set to something sane.

Essentially, the values in your php.ini that need attention are:

post_max_size
file_uploads
upload_max_filesize
memory_limit (if enabled on compilation --enable-memory-limit)
max_execution_time
max_input_time

Below are two very good references about file uploads and php.ini settings:

http://www.php.net/manual/en/features.f ... tfalls.php
http://www.radinks.com/upload/config.php

Hope that helps. If none of it does, we may want to look into the fact that you are running PHP in CGI mode, although I don't see how that would have an impact.

I have updated my version of the README file to reflect most of the information contained in this post. This new version of the README will be available with the next version which I hope to have out in a week or so.

Let me know if you still have problems.

-Weaver
Public Keys

The primary purpose of the DATA statement is to give names to constants; instead of referring to pi as 3.141592653589793 at every appearance, the variable PI can be given that value with a DATA statement and used instead of the longer form of the constant. This also simplifies modifying the program, should the value of pi change.
-- FORTRAN manual for Xerox Computers
PROfessional Member
User avatar
Posts: 1967
Joined: Wed Jun 19, 2002 12:05 am
Location: /home/weaver/

Postby Dalsim » Fri May 14, 2004 4:28 pm

Did some playing with the settings and still having the problems, so I set them back to how they were.

As for PHP running in CGI mode..... I have no idea on that one. I'll have to talk to Aaron (my techy) on that one. He is the one that set my server up and maintains it.
"Life is merely a fraction of a second. An infinitely small amount of time to fulfill our desires, our dreams, our passions." Paul Gauguin (1848 - 1904)
AEST
PROfessional Member
Posts: 1119
Joined: Sun Jun 15, 2003 7:07 am
Location: Queensland, Australia

Postby Weaver » Fri May 14, 2004 4:48 pm

Alright then, it sounds to me like it may be an Apache issue. I think I may have interpreted your problem wrong. The files are actually getting uploaded succesfully correct? You just receive the error when trying to access them right away correct?

A 401 error deals with being unauthorised because the browser has not sent the correct (or any) authentication information when it is required.

http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html

Your Apache config may NOT be setup incorrectly, it may just be setup with a very secure or harsh '/' level ruleset/options. You should run through your httpd.conf file to make sure that authentication (basic or digest style) authentication is required in the specific directory or in some weird '/' level directive.

Also check to make sure that you don't have an .htaccess file that requires authentication in your home directory or in your public_html/htdocs directory, or any directory that is a parent to $UPLOAD_DIR . .htaccess files are inherited by child directories (one of the reasons they slow down web servers).

All in all, now that I have a better understanding of the situation, it sounds to me like an Apache configuration or .htaccess issue. Consult your techie if you aren't familiar.

-Weaver
Public Keys

The primary purpose of the DATA statement is to give names to constants; instead of referring to pi as 3.141592653589793 at every appearance, the variable PI can be given that value with a DATA statement and used instead of the longer form of the constant. This also simplifies modifying the program, should the value of pi change.
-- FORTRAN manual for Xerox Computers
PROfessional Member
User avatar
Posts: 1967
Joined: Wed Jun 19, 2002 12:05 am
Location: /home/weaver/

Postby Dalsim » Fri May 14, 2004 4:53 pm

Yes the files are being uploaded successfully I just can not access them afterwards if I upload with your script. The thing is I don't have the same problem when I use other upload scripts.
"Life is merely a fraction of a second. An infinitely small amount of time to fulfill our desires, our dreams, our passions." Paul Gauguin (1848 - 1904)
AEST
PROfessional Member
Posts: 1119
Joined: Sun Jun 15, 2003 7:07 am
Location: Queensland, Australia

Postby Weaver » Fri May 14, 2004 5:10 pm

The only advice that I can offer is that you troubleshoot. I have tested the script on multiple *nix systems without hitch. Consult your Apache logs, access logs, error logs, etc. Check permissions. Compare the permission set and ownership of the files to the UID and GID that Apache is running as.

I don't know what more I can tell you, since you have access to the machine you are going to have put those troubleshooting skills to the test. If the files are getting uploaded successfully, then the script has done its job. When you access the files afterwards, the script isn't executing.

It sounds to me like either a configuration (httpd.conf/.htaccess) issue or a permissions issue. Like I mentioned above, be sure that permissions are are all correct. The script uses move_uploaded_file() which plays games with the permissions/etc.

Use your best judgement.

-Weaver
Public Keys

The primary purpose of the DATA statement is to give names to constants; instead of referring to pi as 3.141592653589793 at every appearance, the variable PI can be given that value with a DATA statement and used instead of the longer form of the constant. This also simplifies modifying the program, should the value of pi change.
-- FORTRAN manual for Xerox Computers
PROfessional Member
User avatar
Posts: 1967
Joined: Wed Jun 19, 2002 12:05 am
Location: /home/weaver/

Postby Dalsim » Sat May 15, 2004 1:33 am

Use my best judgement. Yea totally new to the *nix environment. I'll talk to my techie on this.

Thanks for the help.
"Life is merely a fraction of a second. An infinitely small amount of time to fulfill our desires, our dreams, our passions." Paul Gauguin (1848 - 1904)
AEST
PROfessional Member
Posts: 1119
Joined: Sun Jun 15, 2003 7:07 am
Location: Queensland, Australia

Return to HTML, CSS, and Scripts

Who is online

Users browsing this forum: No registered users and 3 guests

cron
cron