azraelGG Posted December 11, 2012 Share Posted December 11, 2012 i looked some tutorial how to upload files, and got some script i should use for that, but i cant set good values for my destination folder i guess can you tell me where do i get things wrong if(!empty($_FILES)){ $tempFile = str_replace(" ", "", $_FILES['picUpload']['tmp_name']); $targetPath = $_SERVER['DOCUMENT_ROOT'].'/images/mehanizacija/'; $broj = rand(100,999); $targetFile = str_replace(" ", "", $targetPath.$broj.'-'.$_FILES['picUpload']['name']); $linkPicture = str_replace(" ", "", "http://localhost/images/mehanizacija/".$broj.'-'.$_FILES['picUpload']['name']); move_uploaded_file($tempFile, $targetFile); } Warning: move_uploaded_file(/home/azrael/htdocs/images/mehanizacija/408-pics01.jpg): failed to open stream: No such file or directory in /home/azrael/htdocs/agro/stroj.php on line 76 Warning: move_uploaded_file(): Unable to move '/tmp/phpKEpgr3' to '/home/azrael/htdocs/images/mehanizacija/408-pics01.jpg' in /home/azrael/htdocs/agro/stroj.php on line 76 line76 move_uploaded_file($tempFile, $targetFile); i use submit button from form that have multiple forms so i need that if(!empty($_FILES)) and in $linkPicture can i also use $_SERVER['DOCUMENT_ROOT'] so if i send this to some server he will look in my root folder and not directly on link that i will need to change Quote Link to comment https://forums.phpfreaks.com/topic/271867-file-upload-problem/ Share on other sites More sharing options...
MDCode Posted December 11, 2012 Share Posted December 11, 2012 (edited) The error is clear, the directory doesn't exist. You are calling the the directory of storage by path and file. I think you mean $targetPath Edited December 11, 2012 by SocialCloud Quote Link to comment https://forums.phpfreaks.com/topic/271867-file-upload-problem/#findComment-1398743 Share on other sites More sharing options...
Stooney Posted December 11, 2012 Share Posted December 11, 2012 It's just telling you that your destination folder doesn't exist. You'll need to either create it manually or use mkdir(). This folder needs to be created before you can put stuff in it: /home/azrael/htdocs/images/mehanizacija/ Quote Link to comment https://forums.phpfreaks.com/topic/271867-file-upload-problem/#findComment-1398744 Share on other sites More sharing options...
azraelGG Posted December 11, 2012 Author Share Posted December 11, 2012 yea... my root foler is not what i tought it is... missing name of project in it Quote Link to comment https://forums.phpfreaks.com/topic/271867-file-upload-problem/#findComment-1398745 Share on other sites More sharing options...
Christian F. Posted December 12, 2012 Share Posted December 12, 2012 Also, I wonder if you can explain why you're doing this? $tempFile = str_replace(" ", "", $_FILES['picUpload']['tmp_name']); Not only is it quite unnecessary because the temp name never contains a space, but what would have happened if it did..? Quote Link to comment https://forums.phpfreaks.com/topic/271867-file-upload-problem/#findComment-1398875 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.