Jump to content

Recommended Posts

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>

<body>

<form name="form1" method="post" action="" enctype="multipart/form-data">
<input type="file" name="imagefile" />
<br />
<input type="submit" name="Submit" value="Submit" />

<?

if(isset( $Submit))
{
//Als er op de Submitknop was geduwd doe:

if ($_FILES['imagefile']['type'] == "image/gif"){ 
copy ($_FILES['imagefile']['tmp_name'], "uploads/" . $_FILES['imagefile']['nam'])
or die ("Could not copy");

        echo ""; 
        echo "Name: ".$_FILES['imagefile']['name'].""; 
        echo "Size: ".$_FILES['imagefile']['size'].""; 
        echo "Type: ".$_FILES['imagefile']['type'].""; 
        echo "Copy Done...."; 
        } 
	  else {
            echo "<br><br>";
            echo "Could Not Copy, Wrong Filetype (".$_FILES['imagefile']['name'].")<br>";
        }
} 
?>
</form>
</body>
</html>

 

Hello guys,

 

i've got a problem, I read the tutorial of your website but i've got a problem, the image won't upload...

can someone help me?

Link to comment
https://forums.phpfreaks.com/topic/64810-solved-image-upload/
Share on other sites

I don't have anything setup my side to check the code, but this could be the solution:

 

<?php

if(isset( $Submit))
{
if ($_FILES['imagefile']['type'] == "image/gif"){ 
copy ($_FILES['imagefile']['tmp_name'], "uploads/" . $_FILES['imagefile']['name'])
or die ("Could not copy");

        echo ""; 
        echo "Name: ".$_FILES['imagefile']['name'].""; 
        echo "Size: ".$_FILES['imagefile']['size'].""; 
        echo "Type: ".$_FILES['imagefile']['type'].""; 
        echo "Copy Done...."; 
        } 

  else {
            echo "<br><br>";
            echo "Could Not Copy, Wrong Filetype (".$_FILES['imagefile']['name'].")<br>";
        }
} 
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<form name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" enctype="multipart/form-data">
<input type="file" name="imagefile" />
<br />
<input type="submit" name="Submit" value="Submit" />
</form>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/64810-solved-image-upload/#findComment-323368
Share on other sites

This just worked for me:

 

if ($imagefile != "")
{
   $target_path = "images/" . basename( $_FILES['imagefile']['name']);
   if(!move_uploaded_file($_FILES['imagefile']['tmp_name'], $target_path)) {
       echo "There was an error uploading the imagefile, please try again!";
   }   
}

Link to comment
https://forums.phpfreaks.com/topic/64810-solved-image-upload/#findComment-323399
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.