denechtew Posted August 14, 2007 Share Posted August 14, 2007 <!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? Quote Link to comment https://forums.phpfreaks.com/topic/64810-solved-image-upload/ Share on other sites More sharing options...
PhaZZed Posted August 14, 2007 Share Posted August 14, 2007 Does the folder you are trying to upload to have the correct permissions? CHMOD 755 Quote Link to comment https://forums.phpfreaks.com/topic/64810-solved-image-upload/#findComment-323301 Share on other sites More sharing options...
denechtew Posted August 14, 2007 Author Share Posted August 14, 2007 I thought it was Chmod777 Quote Link to comment https://forums.phpfreaks.com/topic/64810-solved-image-upload/#findComment-323311 Share on other sites More sharing options...
PhaZZed Posted August 14, 2007 Share Posted August 14, 2007 That gives everyone write permissions, including the public, which means they can delete the folder Quote Link to comment https://forums.phpfreaks.com/topic/64810-solved-image-upload/#findComment-323314 Share on other sites More sharing options...
denechtew Posted August 14, 2007 Author Share Posted August 14, 2007 http://scampiml.com/warre/upload/upload2.php I've set it on 755... Quote Link to comment https://forums.phpfreaks.com/topic/64810-solved-image-upload/#findComment-323321 Share on other sites More sharing options...
PhaZZed Posted August 14, 2007 Share Posted August 14, 2007 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> Quote Link to comment https://forums.phpfreaks.com/topic/64810-solved-image-upload/#findComment-323368 Share on other sites More sharing options...
denechtew Posted August 14, 2007 Author Share Posted August 14, 2007 It still doesn't work. http://scampiml.com/warre/upload/upload2.php Quote Link to comment https://forums.phpfreaks.com/topic/64810-solved-image-upload/#findComment-323383 Share on other sites More sharing options...
PhaZZed Posted August 14, 2007 Share Posted August 14, 2007 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!"; } } Quote Link to comment https://forums.phpfreaks.com/topic/64810-solved-image-upload/#findComment-323399 Share on other sites More sharing options...
denechtew Posted August 14, 2007 Author Share Posted August 14, 2007 I think i've done someting wrong is it possible to post the whole code... I don't see an "outway" anymore. Quote Link to comment https://forums.phpfreaks.com/topic/64810-solved-image-upload/#findComment-323420 Share on other sites More sharing options...
denechtew Posted August 14, 2007 Author Share Posted August 14, 2007 "bump"* Quote Link to comment https://forums.phpfreaks.com/topic/64810-solved-image-upload/#findComment-323538 Share on other sites More sharing options...
denechtew Posted August 14, 2007 Author Share Posted August 14, 2007 I found it it works . thanks ! Quote Link to comment https://forums.phpfreaks.com/topic/64810-solved-image-upload/#findComment-323570 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.