mechedd Posted October 16, 2009 Share Posted October 16, 2009 Hi again, Last post for tonight! I promise! Ok, so I now have the $_FILES array working fine... I can call on the file name and type and tmp_name. Now I am trying to move the file to a directory on the server (I am hosted by GoDaddy), but I cannot figure out how to write the directory so that it works. GoDaddy gives me an "Absolute Hosting Path", which is something along the lines of D:\Hosting\123456\.... The temporary directory (which I find by calling the $_FILES array) is something similar, but more like D:\Temp\.... So I have a folder called Upload and I want to move the temp file to this folder. I tried doing: move_uploaded_file($_FILES["File1"]["tmp_name"], "D:\Hosting\123456\html\upload\" . "\" . $_FILES["File1"]["name"]); But it doesnt like the \ and I get an error. Plus, the directories on my website use forward slashes.... what do i have to do? Do I have all of the information I need? Do I use the Absolute Hosting Path? Quote Link to comment https://forums.phpfreaks.com/topic/177864-solved-move_uploaded_file/ Share on other sites More sharing options...
Alex Posted October 16, 2009 Share Posted October 16, 2009 You need to remove that additional \. Say you uploaded a file named "hello.jpg", the string created would be: D:\Hosting\123456\html\upload\\hello.jpg You want: D:\Hosting\123456\html\upload\hello.jpg so: move_uploaded_file($_FILES["File1"]["tmp_name"], "D:\Hosting\123456\html\upload\{$_FILES["File1"]["name"]}"); Quote Link to comment https://forums.phpfreaks.com/topic/177864-solved-move_uploaded_file/#findComment-937832 Share on other sites More sharing options...
mechedd Posted October 16, 2009 Author Share Posted October 16, 2009 I just tried that and I get this: Warning: move_uploaded_file(D:\HostingE3020\html\uploaddbf09front.JPG) [function.move-uploaded-file]: failed to open stream: No such file or directory in D:\Hosting\123456\html\phptest.php on line 24 Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'D:\Temp\php\phpE0E5.tmp' to 'D:\HostingE3020\html\uploaddbf09front.JPG' in D:\Hosting\123456\html\phptest.php on line 24 I can see two errors here. The first is that the file and directory do not have a \ between them when I leave it out. (uploaddbf09front.JPG) Second, the Absolute Hosting Path was switched somehow... It is supposed to be D:\Hosting\123456\html\..... and ad you can see it got switched to D:\HostingE3020\html\.... I dont know what is going on I have the path right in my script. Any Ideas? -mechedd Quote Link to comment https://forums.phpfreaks.com/topic/177864-solved-move_uploaded_file/#findComment-937834 Share on other sites More sharing options...
Alex Posted October 16, 2009 Share Posted October 16, 2009 Sorry, tired. Use: move_uploaded_file($_FILES["File1"]["tmp_name"], 'D:\Hosting\123456\html\upload\\' . $_FILES['File1']['name']); Quote Link to comment https://forums.phpfreaks.com/topic/177864-solved-move_uploaded_file/#findComment-937840 Share on other sites More sharing options...
mechedd Posted October 16, 2009 Author Share Posted October 16, 2009 When I try that I get: Warning: move_uploaded_file(D:\Hosting\123456\html\upload\dbf09side.JPG) [function.move-uploaded-file]: failed to open stream: Permission denied in D:\Hosting\123456\html\phptest.php on line 24 Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'D:\Temp\php\php4194.tmp' to 'D:\Hosting\123456\html\upload\dbf09side.JPG' in D:\Hosting\123456\html\phptest.php on line 24 Permission is denied... The good thing is the file path now appears how it should. Is this something I have to call GoDaddy about or is there some way to grant permission? -mechedd Quote Link to comment https://forums.phpfreaks.com/topic/177864-solved-move_uploaded_file/#findComment-938017 Share on other sites More sharing options...
Alex Posted October 16, 2009 Share Posted October 16, 2009 You'll need to CMOD to file to give it permissions, try 777. Quote Link to comment https://forums.phpfreaks.com/topic/177864-solved-move_uploaded_file/#findComment-938245 Share on other sites More sharing options...
mechedd Posted October 16, 2009 Author Share Posted October 16, 2009 I got it to work. With GoDaddy you have to create a directory in the IIS Manager and wait half a day for them to set it up for you if you want to be able to give the directory web writable permissions. Thanks for all of your help! -mechedd Quote Link to comment https://forums.phpfreaks.com/topic/177864-solved-move_uploaded_file/#findComment-938400 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.