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
    Regular Coder
    Join Date
    Sep 2004
    Posts
    713
    Thanks
    6
    Thanked 2 Times in 2 Posts

    strange upload problem

    Code:
    <table width="100%" align="center" border="0" cellspacing="1" cellpadding="4">
    <form action="/news/admin/organisation.php" enctype="multipart/form-data" method="post" name="" >
    <tr id="cat">
    	<td class="tblhead" colspan="2"><b>Add Organisation</b></td>
    </tr>
    <tr class="firstalt" nowrap>
    	<td valign="top">Attachment:</td>
    	<td id="upid"><input class="fileinput" type="file" name="attachment1" size="30"></td>
    </tr>
    <tr class="secondalt" nowrap>
    	<td valign="top">Attachment:</td>
    	<td id="upid"><input class="fileinput" type="file" name="attachment2" size="30"></td>
    </tr>
    <tr class="firstalt" nowrap>
    	<td valign="top">Attachment:</td>
    	<td id="upid"><input class="fileinput" type="file" name="attachment3" size="30"></td>
    </tr>
    <tr class="secondalt" nowrap>
    	<td valign="top">Attachment:</td>
    	<td id="upid"><input class="fileinput" type="file" name="attachment4" size="30"></td>
    </tr>
    <tr class="firstalt" nowrap>
    	<td valign="top">Attachment:</td>
    	<td id="upid"><input class="fileinput" type="file" name="attachment5" size="30"></td>
    </tr>
    <input type="hidden" name="action" value="addorg">
    <input type="hidden" name="id" value="2">
    <tr class="tblhead">
    <td colspan="2" align="center">
     <input class="formbutton" accesskey="y" type="submit" name="submit" value="Submit" >
     <input class="formbutton" accesskey="r" type="reset" name="" value="Reset" >
    </td></tr>
    </form>
    </table>
    above is my upload script, however when i upload, i cannot see anything
    Code:
    if($_POST['action']=="addorg"){
    	$newsid=$_POST['id'];
    	   print_r($_FILES['attachment1']);
    	   echo count($_FILES['attachment1']);
    }
    can anyone help me?
    flying dagger

  • #2
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,026
    Thanks
    2
    Thanked 314 Times in 306 Posts
    Assuming that uploads are enabled to begin with, if the $_FILES variable is null, the most likely reason is that the upload file size exceeds the POST_MAX_SIZE directive in php.ini.
    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
    Regular Coder
    Join Date
    Sep 2004
    Posts
    713
    Thanks
    6
    Thanked 2 Times in 2 Posts
    hi, the size of picture only 7kb, i think problem lies elsewhere
    flying dagger

  • #4
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,026
    Thanks
    2
    Thanked 314 Times in 306 Posts
    Your code works on my test system, so there are no typo's that prevent it from working.
    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.

  • #5
    Regular Coder
    Join Date
    Sep 2004
    Posts
    713
    Thanks
    6
    Thanked 2 Times in 2 Posts
    hi, what is the result shown on your system, i am getting empty array
    flying dagger

  • #6
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,026
    Thanks
    2
    Thanked 314 Times in 306 Posts
    Code:
    Array ( [name] => myphoto.JPG [type] => image/pjpeg [tmp_name] => C:\WINDOWS\TEMP\php47.tmp [error] => 0 [size] => 1015124 ) 5
    Note: If you use the following, it will be formated better and will show all the contents of the $_FILES, not just for one -
    PHP Code:
    echo "<pre>";
    print_r($_FILES);
    echo 
    "</pre>"
    This code outputs the following (I only selected a file in the first form field) -
    Code:
    Array
    (
        [attachment1] => Array
            (
                [name] => myphoto.JPG
                [type] => image/pjpeg
                [tmp_name] => C:\WINDOWS\TEMP\php47.tmp
                [error] => 0
                [size] => 1015124
            )
    
        [attachment2] => Array
            (
                [name] => 
                [type] => 
                [tmp_name] => 
                [error] => 4
                [size] => 0
            )
    
        [attachment3] => Array
            (
                [name] => 
                [type] => 
                [tmp_name] => 
                [error] => 4
                [size] => 0
            )
    
        [attachment4] => Array
            (
                [name] => 
                [type] => 
                [tmp_name] => 
                [error] => 4
                [size] => 0
            )
    
        [attachment5] => Array
            (
                [name] => 
                [type] => 
                [tmp_name] => 
                [error] => 4
                [size] => 0
            )
    
    )
    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.


  •  

    Posting Permissions

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