problems uploading files through a form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • raamay
    New Member
    • Feb 2007
    • 107

    problems uploading files through a form

    i have a form which allows files to be uploaded. i have no problem with the upload script as it works perfectly within my local web server. As i host it in my hosting server the upload do not work. i have checked for the php settings in both my local server as well as my hosting server. I have set the local settings as in the hosting server with a few things not identical. One is the upload_tmp_dir which is set in my server but not in the hosting server. So, after some googling i could come across the problem of upload_tmp_dir which could be a reason in my case. So, how should i confirm this or solve this problem?

    if you would like to view my code, its here:
    Code:
    function($fname, $tmpfile){
    $ext = str_replace(".","",strtolower(substr($fname, -4, 4))); 
    $new = strtotime("now");
    $newname = $new.".".$ext;
    if(move_uploaded_file($tmpfile, "files/{$newname}")) {
       ...... then here goes the code to insert the form 
    values along with the file path
    }
    }
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    Try turning on error reporting to aid with debugging.

    Do you have access to the server (more precisely, PHP's configuration)?

    Comment

    • TheServant
      Recognized Expert Top Contributor
      • Feb 2008
      • 1168

      #3
      So echo ini_get('upload _tmp_dir'); returns NULL?

      I think that it's set in your php.ini file. Do you have access to that?
      Add this to your php.ini (if it's not already there) to try a test:
      file_uploads = On
      upload_tmp_dir = {your directory}

      I am sorry if you have already tried this, but let's just make sure the thing is plugged in!

      Comment

      • raamay
        New Member
        • Feb 2007
        • 107

        #4
        since you are online, i submit the error that i get when i try to upload a file. i have put on error reporting. The following is the error:
        Code:
        Warning: move_uploaded_file(files/1253849403.doc) [function.move-uploaded-file]: failed to open stream: Permission denied 
        Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/var/tmp/phpHBrCgj' to 'files/1253849403.doc'
        May be you have some idea about this. Its surely to do with the upload_tmp_dir.

        Comment

        • zorgi
          Recognized Expert Contributor
          • Mar 2008
          • 431

          #5
          Originally posted by raamay
          Code:
          Permission denied
          May be you have some idea about this. Its surely to do with the upload_tmp_dir.
          Try changing permissions for that directory/file

          Comment

          Working...