What is the problem

Discussion in 'PHP' started by cynical_tear, Jul 29, 2009.

  1. #1
    I don't know why this code isn't executing...
    My only problem is that file is not transferring to my desired folder i.e., uploadedsnaps.. I'm able to fetch all the data such as snap name, its size, its type but file isn't moving to where i want iit to move.,.. please help me ..

    <form action=prob.php method=POST enctype='multipart/form-data'>
    
    	<input type='file' name='snap1'><p/>
    
    	<input type='submit' name='uploadsnaps' value='Upload Snaps'><br/><br/>
    
    </form>
    
    <?php
    if($_POST['uploadsnaps'])
    {
    	$name1 		= $_FILES['snap1']['name'];
    	$size1 		= $_FILES['snap1']['size'];
    	$type1 		= $_FILES['snap1']['type'];
    	$temp1 		= $_FILES['snap1']['temp_name'];
    	$error1		= $_FILES['snap1']['error'];		
    
    [COLOR="Green"]	// uploadedsnaps is my forder where i store photos
    [/COLOR]	$location = "uploadedsnaps/$name1";
    	move_uploaded_file($temp1,$location);
    }
    ?>
    Code (markup):

     
    cynical_tear, Jul 29, 2009 IP
  2. Martinoes

    Martinoes Peon

    Messages:
    110
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Typical reasons for inability to transfer file:
    - Lack of rights to destination directory
    - Safe mode
    - There are no designated directory
    - File with the same name is lock by another application
    - No space

    but in this case i think that you should give full path to your file, with disc letter etc.
     
    Martinoes, Jul 29, 2009 IP
  3. Ntech

    Ntech Peon

    Messages:
    33
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Could it be that your path is incomplete?

    When I've had problems like this in the past it turned out I had to spell out the complete path like:

    $location = "/home/x-user/public_html/uploadedsnaps/$name1";
     
    Ntech, Jul 29, 2009 IP
  4. cynical_tear

    cynical_tear Peon

    Messages:
    107
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    The problem is fixed..

    The main problem was i was using
    $temp1 		= $_FILES['snap1']['temp_name']
    Code (markup):
    instead of
    $temp1 		= $_FILES['snap1']['tmp_name']
    Code (markup):
    Thanx for all your suggestion...
     
    cynical_tear, Aug 4, 2009 IP