Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Feb 2007
    Location
    Indianapolis, IN
    Posts
    35
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Uploading issue with different server

    Good morning all. I have been working on a file/newsletter admin system and it runs flawlessly on my local machine (MAMP on Mac). However, when i put it online to the host that I plan on using, it doesnt want to upload any file i throw at it. It just errors out with my error message.

    Here is a snip of my code that deals with the file upload:
    PHP Code:
        //assign post data
        
    $title $_POST['newstitle'];
        
    $code $_POST['newscode'];
        
    $booklets implode(',',$_POST['newsbooklets']);
        
    $sections implode(',',$_POST['sections']);
        
    $date date("F j, Y");
        
    $uploadDir 'documents/newsletters/';
        
        
    //upload file routine
        
    if(isset($_FILES['userfile']['name']))
            {
                
    $fileName $_FILES['userfile']['name'];
                
    $tmpName $_FILES['userfile']['tmp_name'];
                
    $fileSize $_FILES['userfile']['size'];
                
    $fileType $_FILES['userfile']['type'];
                
                
    $filePath $uploadDir $fileName;
                
                
    $result move_uploaded_file($tmpName$filePath);
                
                if (!
    $result
                    {
                        echo 
    "Error uploading file.";
                        exit;
                    }

                if(!
    get_magic_quotes_gpc())
                    {
                        
    $fileName addslashes($fileName);
                        
    $filePath addslashes($filePath);
                    }
            } 
    $result seems to be empty since that is where it is erroring out. I kind of have a feeling it might be some type of configuration of my host (1and1.com). If anyone could possibly assist me with this, i'd greatly appreciate it.

    Thanks

  • #2
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,026
    Thanks
    2
    Thanked 315 Times in 307 Posts
    Either check your server log for errors or put the following two lines in after your first opening <?php tag -
    PHP Code:
    ini_set ("display_errors""1");
    error_reporting(E_ALL); 
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • #3
    New Coder
    Join Date
    Feb 2007
    Location
    Indianapolis, IN
    Posts
    35
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Thanks for the idea of checking out the logs, who would of thought? It has been a rather hazy morning thus far.. Anyways, onto what I found.

    I used a method for creating error log files suggested by 1and1, since I do not have direct access to the raw logs. Here is the error it outputs.
    "01 Mar 2007 10:28:58","/homepages/6/d194824923/htdocs/docadmin/adddata.php:
    31","(Warning) move_uploaded_file() [<a href='function.move-uploaded-file'>function.move-uploaded-file</a>]: Unable to move '/tmp/phpzE7rwN' to 'documents/newsletters/test.txt'"
    Obviously it is having trouble either locating the temp file, or moving it. Anyone familiar with how 1and1 handles file uploads or am I just missing something here? Thanks

  • #4
    Senior Coder
    Join Date
    Jan 2007
    Posts
    1,648
    Thanks
    1
    Thanked 58 Times in 54 Posts
    Perhaps PHP does not have access to the temporary folder, or the folder it is moving to.

    Did you check to see whether the temporary file exists using file_exists()?

  • #5
    New Coder
    Join Date
    Feb 2007
    Location
    Indianapolis, IN
    Posts
    35
    Thanks
    3
    Thanked 0 Times in 0 Posts
    It seems to exist:
    File exists: /tmp/phpoOYwET
    It is still producing the same error:
    "(Warning) move_uploaded_file() [<a href='function.move-uploaded-file'>function.move-uploaded-file</a>]: Unable to move '/tmp/phpoOYwET' to 'documents/newsletters/test.txt'"

  • #6
    New Coder
    Join Date
    Feb 2007
    Location
    Indianapolis, IN
    Posts
    35
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Fixed it. I set the upload directory relative to the document root
    PHP Code:
    $uploadDir $_SERVER['DOCUMENT_ROOT'] . "documents/newsletters/"
    instead of just:
    PHP Code:
    $uploadDir 'documents/newsletters/'


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •