php upload

  • Started
  • Last post
  • 2 Responses
  • aplus

    I am using a php class to handle uploads to my web server running apache. I can upload with no problems but once the files are on the server I cannot d/l or rename them via ftp. The permissions for the individual files are changed to "apache" as the owner. Any ideas why this would happen and/or a fix? Thanks.

  • chimchim0

    use chmod and chown

    set mod to 0775 or 0777.

    make sure the folder you are uploading into has these permissions as well.

    For the owner and group...not sure what's best for your system - but it doesn't really matter once you set permissions to 0777.

    take a look at all the info over at php.net

  • enobrev0

    It has t odo wit hthe server setup. You mnay or may not be able to chown it t othe correct user depednign on the setup.

    Basically, a lot of web server admins give apache it's own loagin to the server ot ensure security. It keeps apache based stuff (like file uploads) away from the rest of the system.

    PHP runs as the apache user (again depending on the server setup, which seems to be the case for oyu). So when you upload the file, php saves it to the drive as it's own user, apache.

    You can TRY to use the chown function and change it to your ftp username, but then it's possible that you won't have access to it from a browser (since the browser would go through apache, aka the apache user).

    You can also try to set the chmod (permissions) of the file to 0777 upon upload. This will allow access to the file properly, BUT some server setups don't allow changing the apache user to change the permissions of a file.

    Definnitely a clusterfuck of sorts. If nothing works, you could also try storing the file in the database. Most databses, mysql included have data field of type 'blob'. This will allow you to properly store a binary file in the database and retrieve it later. You'll have to research the 'how' of it, but there should be plenty of info out there about storing and retriving files to/from the db properly.

    I generally recommend agasint storing files in the DB unles you abosolutely have to (As may be the case here), as it's best to use the file system for file storage, but do what yo uhave to to get the job done.

    Good Luck!