Nodral Posted July 19, 2011 Share Posted July 19, 2011 Hi I'm desperately going round in circles here trying to work out a save path for a file. Here is my structure. localhost/dir1/dir2/files I need to save in localhost/tmp What file path do I set $filename as? move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], "$filename" Quote Link to comment https://forums.phpfreaks.com/topic/242340-file-path/ Share on other sites More sharing options...
AyKay47 Posted July 19, 2011 Share Posted July 19, 2011 $filename = ../../../tmp or you can use an absolute path Quote Link to comment https://forums.phpfreaks.com/topic/242340-file-path/#findComment-1244640 Share on other sites More sharing options...
Nodral Posted July 19, 2011 Author Share Posted July 19, 2011 Tried this and got the following errors $filename="../../../tmp/user_import.csv"; Warning: move_uploaded_file(../../../tmp/user_import.csv) [function.move-uploaded-file]: failed to open stream: No such file or directory in D:\Documents\AI24\Web\skooch\pfp\uploadFile.php on line 11 Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\WINDOWS\Temp\php427D.tmp' to '../../../tmp/user_import.csv' in D:\Documents\AI24\Web\skooch\pfp\uploadFile.php on line 11 Quote Link to comment https://forums.phpfreaks.com/topic/242340-file-path/#findComment-1244642 Share on other sites More sharing options...
AyKay47 Posted July 19, 2011 Share Posted July 19, 2011 ohh you are using windows.. :-\ you will want to change the "upload_tmp_dir" in your php.ini file and make it a directory near your website directory. Quote Link to comment https://forums.phpfreaks.com/topic/242340-file-path/#findComment-1244645 Share on other sites More sharing options...
Nodral Posted July 19, 2011 Author Share Posted July 19, 2011 This works fine if I save it in the same directory, or move up a level or 2 using ../ etc. However, as soon as I add the tmp directory it falls over. This directory was manually created about 30 seconds before running the script. It is to mirror the structure I will have when I move to my live server. even the absolute path of $filename='localhost/tmp/user_import.csv'; fails Quote Link to comment https://forums.phpfreaks.com/topic/242340-file-path/#findComment-1244647 Share on other sites More sharing options...
AyKay47 Posted July 19, 2011 Share Posted July 19, 2011 if you use the absolute path, what errror(s) are you receiving then? the same ones? Quote Link to comment https://forums.phpfreaks.com/topic/242340-file-path/#findComment-1244650 Share on other sites More sharing options...
Nodral Posted July 19, 2011 Author Share Posted July 19, 2011 Warning: move_uploaded_file(localhost/tmp/user_import.csv) [function.move-uploaded-file]: failed to open stream: No such file or directory in D:\Documents\AI24\Web\skooch\pfp\uploadFile.php on line 11 Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move 'C:\WINDOWS\Temp\php4283.tmp' to 'localhost/tmp/user_import.csv' in D:\Documents\AI24\Web\skooch\pfp\uploadFile.php on line 11 Quote Link to comment https://forums.phpfreaks.com/topic/242340-file-path/#findComment-1244652 Share on other sites More sharing options...
Nodral Posted July 21, 2011 Author Share Posted July 21, 2011 Sorry to bump this, but I need to resolve this final issue then I can go live with my site. Any ideas guys? Quote Link to comment https://forums.phpfreaks.com/topic/242340-file-path/#findComment-1245651 Share on other sites More sharing options...
Muddy_Funster Posted July 21, 2011 Share Posted July 21, 2011 What OS are you using? Is it the same as your production server is using? How did you assign read/write access on the folder? What web server are you using IIS or Apache? What version of PHP are you using? Quote Link to comment https://forums.phpfreaks.com/topic/242340-file-path/#findComment-1245656 Share on other sites More sharing options...
Nodral Posted July 21, 2011 Author Share Posted July 21, 2011 Using Apache, Windows XP and PHP 5.2.13 My web host is the same except for they use php 5.3. I'm unsure how to set up read/write access on the folder, but I've never had an issue with any other folders I've created through windows Quote Link to comment https://forums.phpfreaks.com/topic/242340-file-path/#findComment-1245659 Share on other sites More sharing options...
Nodral Posted July 21, 2011 Author Share Posted July 21, 2011 Here's an update, if I use D:/Documents/AI24/Web/tmp as $filename it works. However I need this to be a relative path for my production server as I don't know the full root path Quote Link to comment https://forums.phpfreaks.com/topic/242340-file-path/#findComment-1245660 Share on other sites More sharing options...
PFMaBiSmAd Posted July 21, 2011 Share Posted July 21, 2011 $_SERVER['DOCUMENT_ROOT'] will give you the file system path to the current document root folder. You can then concatenate a path onto the end of that to get an absolute file system path. Quote Link to comment https://forums.phpfreaks.com/topic/242340-file-path/#findComment-1245667 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.