Results 1 to 3 of 3

Thread: Upload file then headers?

  1. #1
    Join Date
    Jan 2009
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Upload file then headers?

    I am using Dreamweaver CS3. I used their update form feature and have tried altering it a bit. The upload file works, but I keep getting an error that says "Warning: Cannot modify header information - headers already sent by (output started at /home/content/e/v/e/everyscene/html/admin/addbarext.php:59) in /home/content/e/v/e/everyscene/html/admin/addbarext.php on line 76". In my research, I found that there cannot be an output before the header. If I switch them places, the file does not upload. Is there something I am missing or a better way to do this? Thank you

    Code:
    if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "addpic")) {
    	$target = "../includes/barpics/";
    		$target = $target . basename( $_FILES['barpicext']['name']) ;
    		$ok=1;
    		
    		if ($uploaded_size > 1073741824) {
    		echo "Your picture file is too large.<br>";
    		$ok=0; }
    
    		if ($ok==0) {
    		echo "Sorry your picture file was not uploaded"; }
    
    		else {
    		if(move_uploaded_file($_FILES['barpicext']['tmp_name'], $target)) {
    		echo "The file " . basename( $_FILES['barpicext']['name']) . " has been uploaded";
    		} else {
    		echo "Sorry, there was a problem uploading your picture file."; }
    		}
    
      $updateSQL = sprintf("UPDATE bars SET barpicext=%s WHERE barID=%s",
                           GetSQLValueString($_FILES['barpicext']['name'], "text"),
                           GetSQLValueString($_POST['barID'], "int"));
    
      mysql_select_db($database_everyscene, $everyscene);
      $Result1 = mysql_query($updateSQL, $everyscene) or die(mysql_error());
    
      $updateGoTo = "viewbars.php";
      if (isset($_SERVER['QUERY_STRING'])) {
        $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
        $updateGoTo .= $_SERVER['QUERY_STRING'];
      }
      header(sprintf("Location: ", $updateGoTo));
    }
    Last edited by Snookerman; 05-17-2009 at 05:59 PM. Reason: added “Resolved” prefix

  2. #2
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    Removing those echo statements should probably do the job. Since you're wanting to redirect to another page, it doesn't make sense to output an error/success message.

  3. #3
    Join Date
    Jan 2009
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    That worked, thank you

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
  •