Jump to content

Upload successful but file not moving


graham23s

Recommended Posts

Hi Guys,

 

i can't seem to figure this out, i get the message upload successful but the file hasn't moved, any ideas on what could be wrong?

 

  if($_POST['submit']) {
  
    $filesize = $_FILES['usersphoto']['size'];
    $filename = $_FILES['usersphoto']['tmp_name'];
    
    ## vars
    $maxheight = 500;
    $maxwidth = 500;
    
    if($filesize == 0) {
    
     stderr("Upload Failed","No file was uploaded.");
     include("includes/footer.php");
     exit;   
    
    }
    
    $imagedimensions = getimagesize($filename);
    
    $width = $imagedimensions[0];
    $height = $imagedimensions[1];
    
    if($width > $maxwidth || $maxheight > 500) {
    
     stderr("Upload Failed","Images cannot be larger than $maxwidth  x $maxheight, yours was ($width) width and ($height) height, please try again.");
     include("includes/footer.php");
     exit;   
    
    }
    
    $uploaddirectory = 'uploads';
    
    ## Move uploaded file
    if(move_uploaded_file($_FILES['usersphoto']['tmp_name'], $uploaddirectory)) {
    
     stderr("Upload Successful","Upload went well.");
     include("includes/footer.php");
     exit;      
    
    }

 

thanks guys

 

Graham

Link to comment
https://forums.phpfreaks.com/topic/76005-upload-successful-but-file-not-moving/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.