rallokkcaz Posted August 23, 2006 Share Posted August 23, 2006 I can't figure out how to get this to upload to the serverand then if its possible a thumbnail of the pic under that[code]<form name="form1" method="post" action="" enctype="multipart/form-data"> <input type="file" name="imagefile"> <br><input type="submit" name="Submit" value="Submit"> <br> <?php if(isset($Submit)){ $file=$_FILES['imagefile']['name']; $filetype=substr($file,-4); if($filetype=="jpeg"){ copy($_FILES['imagefile']['tmp_name'],"images/".$_FILES['imagefile']['name']) or die("Could not copy"); echo"<br>Upload Complete"; echo"<br>Name: ".$_FILES['imagefile']['name'].""; echo"<br>Size: ".$_FILES['imagefile']['size'].""; echo"<br>Type: ".$_FILES['imagefile']['type']."<br>"; }elseif($filetype==".jpg"){ copy($_FILES['imagefile']['tmp_name'],"images/".$_FILES['imagefile']['name']) or die("Could not copy"); echo"<br>Upload Complete"; echo"<br>Name: ".$_FILES['imagefile']['name'].""; echo"<br>Size: ".$_FILES['imagefile']['size'].""; echo"<br>Type: ".$_FILES['imagefile']['type']."<br>"; }elseif($filetype==".png"){ copy($_FILES['imagefile']['tmp_name'],"images/".$_FILES['imagefile']['name']) or die("Could not copy"); echo"<br>Upload Complete"; echo"<br>Name: ".$_FILES['imagefile']['name'].""; echo"<br>Size: ".$_FILES['imagefile']['size'].""; echo"<br>Type: ".$_FILES['imagefile']['type']."<br>"; }elseif($filetype==".gif"){ copy($_FILES['imagefile']['tmp_name'],"images/".$_FILES['imagefile']['name']) or die("Could not copy"); echo"<br>Upload Complete"; echo"<br>Name: ".$_FILES['imagefile']['name'].""; echo"<br>Size: ".$_FILES['imagefile']['size'].""; echo"<br>Type: ".$_FILES['imagefile']['type']."<br>"; }else{ echo"<br><span class="subtitle">Upload Error</span>"; echo"<br>Could Not Copy, Wrong Filetype (".$_FILES['imagefile']['name'].")<br>"; } } ?> </form>[/code]pleeze help! Link to comment https://forums.phpfreaks.com/topic/18454-file-upload-script-help/ Share on other sites More sharing options...
craygo Posted August 23, 2006 Share Posted August 23, 2006 You cannot use $Submit unless globals are turned on, which they are not by default you have to use $_POST['Submit']Ray Link to comment https://forums.phpfreaks.com/topic/18454-file-upload-script-help/#findComment-79384 Share on other sites More sharing options...
rallokkcaz Posted August 23, 2006 Author Share Posted August 23, 2006 where do i put that ??? Link to comment https://forums.phpfreaks.com/topic/18454-file-upload-script-help/#findComment-79388 Share on other sites More sharing options...
Corona4456 Posted August 23, 2006 Share Posted August 23, 2006 replace '$Submit' in your script with '$_POST['Submit']' Link to comment https://forums.phpfreaks.com/topic/18454-file-upload-script-help/#findComment-79390 Share on other sites More sharing options...
rallokkcaz Posted August 23, 2006 Author Share Posted August 23, 2006 where would i put the script to upload it to the database?and if possible make a thumb nail of it? Link to comment https://forums.phpfreaks.com/topic/18454-file-upload-script-help/#findComment-79394 Share on other sites More sharing options...
rallokkcaz Posted August 23, 2006 Author Share Posted August 23, 2006 Warning: copy(images/BEN.png) [function.copy]: failed to open stream: No such file or directory in /home/pokebash/public_html/pic_upload.php on line 24Could not copythat was the error message i just got what should i do to fix it.[code]<form name="form1" method="post" action="" enctype="multipart/form-data"> <input type="file" name="imagefile"> <br><input type="submit" name="Submit" value="Submit"> <br> <?php if(isset($_POST['Submit'])){ $file=$_FILES['imagefile']['name']; $filetype=substr($file,-4); if($filetype=="jpeg"){ copy($_FILES['imagefile']['tmp_name'],"images/".$_FILES['imagefile']['name']) or die("Could not copy"); echo"<br>Upload Complete"; echo"<br>Name: ".$_FILES['imagefile']['name'].""; echo"<br>Size: ".$_FILES['imagefile']['size'].""; echo"<br>Type: ".$_FILES['imagefile']['type']."<br>"; }elseif($filetype==".jpg"){ copy($_FILES['imagefile']['tmp_name'],"images/".$_FILES['imagefile']['name']) or die("Could not copy"); echo"<br>Upload Complete"; echo"<br>Name: ".$_FILES['imagefile']['name'].""; echo"<br>Size: ".$_FILES['imagefile']['size'].""; echo"<br>Type: ".$_FILES['imagefile']['type']."<br>"; }elseif($filetype==".png"){ copy($_FILES['imagefile']['tmp_name'],"images/".$_FILES['imagefile']['name']) or die("Could not copy"); echo"<br>Upload Complete"; echo"<br>Name: ".$_FILES['imagefile']['name'].""; echo"<br>Size: ".$_FILES['imagefile']['size'].""; echo"<br>Type: ".$_FILES['imagefile']['type']."<br>"; }elseif($filetype==".gif"){ copy($_FILES['imagefile']['tmp_name'],"images/".$_FILES['imagefile']['name']) or die("Could not copy"); echo"<br>Upload Complete"; echo"<br>Name: ".$_FILES['imagefile']['name'].""; echo"<br>Size: ".$_FILES['imagefile']['size'].""; echo"<br>Type: ".$_FILES['imagefile']['type']."<br>"; }else{ echo"<br><span class=\"subtitle\">Upload Error</span>"; echo"<br>Could Not Copy, Wrong Filetype (".$_FILES['imagefile']['name'].")<br>"; } } ?> </form>[/code] Link to comment https://forums.phpfreaks.com/topic/18454-file-upload-script-help/#findComment-79398 Share on other sites More sharing options...
craygo Posted August 23, 2006 Share Posted August 23, 2006 That means it can't find the directorytry using the absolute path insteadreplace these lines[code]copy($_FILES['imagefile']['tmp_name'],"images/".$_FILES['imagefile']['name'])[/code]with this[code]copy($_FILES['imagefile']['tmp_name'],"/home/pokebash/public_html/images/".$_FILES['imagefile']['name'])[/code]Ray Link to comment https://forums.phpfreaks.com/topic/18454-file-upload-script-help/#findComment-79400 Share on other sites More sharing options...
rallokkcaz Posted August 23, 2006 Author Share Posted August 23, 2006 thanks but i figuered out what i did wrong i didn't make a folder called images!! really stupid mistake. Link to comment https://forums.phpfreaks.com/topic/18454-file-upload-script-help/#findComment-79403 Share on other sites More sharing options...
rallokkcaz Posted August 23, 2006 Author Share Posted August 23, 2006 now that ive figuered that out instaed of making a a boring directary page where the pics are stored is possible to make a page that the pics can go to ??? Link to comment https://forums.phpfreaks.com/topic/18454-file-upload-script-help/#findComment-79406 Share on other sites More sharing options...
craygo Posted August 23, 2006 Share Posted August 23, 2006 Yes look up on how to read a directory then lookup the gdlib functions to create thumbnails for the pics.Can't do everything for ya my manRay Link to comment https://forums.phpfreaks.com/topic/18454-file-upload-script-help/#findComment-79432 Share on other sites More sharing options...
rallokkcaz Posted August 23, 2006 Author Share Posted August 23, 2006 Thanks for the help people!! :D Link to comment https://forums.phpfreaks.com/topic/18454-file-upload-script-help/#findComment-79435 Share on other sites More sharing options...
Corona4456 Posted August 23, 2006 Share Posted August 23, 2006 If you feel like looking at some code ... look at phpWebAlbum (google it) and check it out. It uses gd to manipulate images. Link to comment https://forums.phpfreaks.com/topic/18454-file-upload-script-help/#findComment-79440 Share on other sites More sharing options...
litebearer Posted August 23, 2006 Share Posted August 23, 2006 Might also look here. With a little tweaking you can have it do what you want.(be sure to see the example)http://www.nstoia.com/toh/technical/listdir/index.phpLite... Link to comment https://forums.phpfreaks.com/topic/18454-file-upload-script-help/#findComment-79542 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.