telsiin Posted June 14, 2008 Share Posted June 14, 2008 Good Afternoon everyone I have a bit of code I am having some problem with, to upload a pic to a server. Now the code appear to be working but when I check the folder the test image is not there/saved on the server thank you all in advance Antonio <?php if($_FILES[map1] !=" "){ @copy($_FILES[map1][tmp_name], "C:\lordsofansalon\htdocs\DM\mapsrc\".$_FILES[map1][name]) or die("Couldn't copy file please make sure it a jpg and under 2 megs."); } else { die("No Input file specified"); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/110226-solved-upload-file-to-server/ Share on other sites More sharing options...
tapos Posted June 14, 2008 Share Posted June 14, 2008 use move_uploaded_file. http://www.php.net/manual/en/function.move-uploaded-file.php for more file handling information http://www.php.net/manual/en/ref.filesystem.php Quote Link to comment https://forums.phpfreaks.com/topic/110226-solved-upload-file-to-server/#findComment-565589 Share on other sites More sharing options...
hansford Posted June 14, 2008 Share Posted June 14, 2008 try checking that the files exists where you tried to save it to. <?php if(file_exists(){ echo "file exists"; } ?> [code] if it does exist, then it's your FTP programming not updating. close it out and reopen and you'll see your file. [/code] Quote Link to comment https://forums.phpfreaks.com/topic/110226-solved-upload-file-to-server/#findComment-565590 Share on other sites More sharing options...
telsiin Posted June 14, 2008 Author Share Posted June 14, 2008 after run it a few more time I don't it save in the temp folder either Quote Link to comment https://forums.phpfreaks.com/topic/110226-solved-upload-file-to-server/#findComment-565599 Share on other sites More sharing options...
telsiin Posted June 14, 2008 Author Share Posted June 14, 2008 I also get the following confirmation message You Sent :boardmap1.jpg a 75930 byte file with a mine type of image/pjpeg. however I notice the extension is pjpeg and NOT jpeg or jpg <?php if($_FILES[map1] !=" "){ $destination="C:\lordsofansalon\htdocs\DM\mapsrc".$_FILES[map1][name]; $temp=$_FILES[map1][name]; move_upload_file($temp,$destination); or die("Couldn't copy file please make sure it a jpg and under 2 megs."); } else { die("No Input file specified"); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/110226-solved-upload-file-to-server/#findComment-565606 Share on other sites More sharing options...
hansford Posted June 14, 2008 Share Posted June 14, 2008 use move_uploaded_file. http://www.php.net/manual/en/function.move-uploaded-file.php for more file handling information http://www.php.net/manual/en/ref.filesystem.php Quote Link to comment https://forums.phpfreaks.com/topic/110226-solved-upload-file-to-server/#findComment-565626 Share on other sites More sharing options...
telsiin Posted June 18, 2008 Author Share Posted June 18, 2008 Apparently my path was wrong, although I think there another way This seem to be working "C:/lordsofansalon/htdocs/DM/mapsrc/".$_FILES[map1][name]) Quote Link to comment https://forums.phpfreaks.com/topic/110226-solved-upload-file-to-server/#findComment-567762 Share on other sites More sharing options...
DarkWater Posted June 18, 2008 Share Posted June 18, 2008 I also get the following confirmation message You Sent :boardmap1.jpg a 75930 byte file with a mine type of image/pjpeg. however I notice the extension is pjpeg and NOT jpeg or jpg <?php if($_FILES[map1] !=" "){ $destination="C:\lordsofansalon\htdocs\DM\mapsrc".$_FILES[map1][name]; $temp=$_FILES[map1][name]; move_upload_file($temp,$destination); or die("Couldn't copy file please make sure it a jpg and under 2 megs."); } else { die("No Input file specified"); } ?> Read what the message says. pjpeg is the MIME TYPE, not the file extension. IE, being the quirky, Microsoft-made cess pool it is, sends out the Mime Type as pjpeg for jpegs instead of what the other browsers send it out as. And don't trust browser Mime Types. You can alter them if you know what you're doing. =P Quote Link to comment https://forums.phpfreaks.com/topic/110226-solved-upload-file-to-server/#findComment-567777 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.