Re: dont print echo

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Daniel Brown wrote:
On Thu, Feb 28, 2008 at 11:08 PM, Emiliano Boragina
<emiliano.boragina@xxxxxxxxx> wrote:
 When I try the php the echo "no picture =("; is there. How can I do to don't
 appears the message before I upload de picture.

    Here's your code, re-written.

<?
if(isset($_FILES)) {
    // The following regexp handles file extension checking.  Modify
it as needed.
    if(preg_match('/(.*)(bmp|gif|jpeg|jpg|png)$/i',substr(basename(__FILE__),-3,3)))
{
        $folder = 'pictures';

First, the op should use is_uploaded_file() to check and make sure that it is a file that was infact uploaded.
	http://us3.php.net/manual/en/function.is-uploaded-file.php

Secondly, the op should use move_uploaded_file() instead instead of copy.
	http://us3.php.net/manual/en/function.move-uploaded-file.php

They were created for a reason

        if(copy($_FILES['file']['tmp_name'] , $folder . '/' .
$_FILES['file']['name']))
            echo "Picture upload!";
        } else {
            echo "no picture =(";
        }
    } else {
        // Handle your "incorrect file type" errors here.
        die("Incorrect file type.");
    }
}
?>
<form action="<?=$_SERVER['PHP_SELF'];?>" method="post"
enctype="multipart/form-data">
<!--
    These fields are hidden.  You can only have one submit button per form,
    and we're only dealing with the image uploads with this question.

At least in "HTML 4 Specification" you can have more then one submit button.

http://www.w3.org/TR/html4/interact/forms.html#submit-button


   <input type="text" name="folder">
   <input type="submit" value="ADD FOLDER">
   <hr>
-->
   <input type="file" name="file">
   <input type="submit" value="UPLOAD">
</form>



--
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
       and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
    by William Shakespeare

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux