SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot
    Join Date
    Oct 2006
    Location
    Syracuse, NY
    Posts
    118
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    File Upload Issues

    Hey everyone. I'm having trouble uploading files to my server. I believe the code should work.. I'm just not sure if everything in my PHP.ini file is right.

    Code:
    <?php
    
    if(empty($_POST)) {
    	$status = '';
    }
    else {
    	$target = "upload/";
    	$target = $target . basename( $_FILES['uploaded']['name']) ;
    	$ok=1;
    
    	if ($ok==0)
    		{
    			Echo "Sorry your file was not uploaded";
    		}
    
    	else
    		{
    				if(move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
    			{
    				echo "The file ".
    				basename( $_FILES['uploadedfile']['name']). " has been uploaded";
    			}
    		else
    			{
    				echo "There was a problem uploading your file.";
    		}
    	}
    }
    ?>
    
    				
    
    <h1>Add URB Policy Form - Admin Section</h1>
    	<?php echo $status; ?>
    	        <form action="add-policy-form.php" method="post" enctype="multipart/form-data">
    							<dl>
    								<dt><label for="p_name">Form Name:</label></dt>
    								<dd><input style="width:200px;" type="text" name="p_name" id="p_name" value="<?php echo $p_name; ?>" /><br/><br/></dd>
    								
    								<dt><label for="p_form_type">Form Type:</label></dt>
    								<dd><input style="width:300px;" type="text" name="p_form_type" id="p_form_type" value="<?php echo $p_form_type; ?>" /><br/><br/></dd>
    								
    								<dt><label for="uploaded">Upload File (.pdf only)</label></dt>
    								<dd><input type="file" name="uploaded" id="uploaded" /></dd>
    								
    							</dl>
    							<div>
    								<input type="submit" name="submit" value="Add Policy Form" />
    								<input type="reset" name="reset" value="Reset Form" />
    							</div>
    						</form>
    </body>
    </html>
    If anyone has some ideas I'd appreciate it!

  2. #2
    play of mind Ernie1's Avatar
    Join Date
    Sep 2005
    Posts
    1,252
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    if(filesize($_FILES['uploaded']['tmp_name'])==0){
        
    $status '';
        }else{
        
    $target "upload/";
        
    $target $target basename($_FILES['uploaded']['name']) ;
        
    $ok 1;
        
        if (
    $ok == 0){
            echo 
    "Sorry your file was not uploaded";
            }else{
            if(
    move_uploaded_file($_FILES['uploaded']['tmp_name'], $target))
                {
                echo 
    "The file " basename($_FILES['uploaded']['name']) . " has been uploaded";
                }else{
                echo 
    "There was a problem uploading your file.";
                }
            }
        } 
    my mobile portal
    ghiris.ro

  3. #3
    SitePoint Zealot
    Join Date
    Oct 2006
    Location
    Syracuse, NY
    Posts
    118
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey thanks man. It still won't upload though... It's gotta be on the server side somewhere...

    http://midstatemutual.net/php_info.php
    I have file uploads on... Not sure what else to do!


Bookmarks

Posting Permissions

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