shanejones Posted September 9, 2010 Share Posted September 9, 2010 I am using a script found off the web to upload file and show a ajaxy waiting image. In the code for the actual upload is this code $destination_path = getcwd().DIRECTORY_SEPARATOR; $result = 0; $target_path = $destination_path . basename( $_FILES['myfile']['name']); if(@move_uploaded_file($_FILES['myfile']['tmp_name'], $target_path)) { $result = 1; } I am running it from domain.com/label/manage/add-file/upload.php and it uploads the file to domain.com/label/manage/add-file/ How can I upload the file to domain.com/files/123/432/ Do I need to modify the destination path? Also do i need to start it from /home/user/......... Thanks Link to comment https://forums.phpfreaks.com/topic/212996-uploading-a-file-to-a-specific-location/ Share on other sites More sharing options...
schilly Posted September 9, 2010 Share Posted September 9, 2010 If you want an absolute path then use /home/user/.... whatever. If you want a relative path just use ../../../files/123/123/ Link to comment https://forums.phpfreaks.com/topic/212996-uploading-a-file-to-a-specific-location/#findComment-1109330 Share on other sites More sharing options...
shanejones Posted September 9, 2010 Author Share Posted September 9, 2010 Should that go in the destination part then? what is this getcwd() too? Link to comment https://forums.phpfreaks.com/topic/212996-uploading-a-file-to-a-specific-location/#findComment-1109336 Share on other sites More sharing options...
schilly Posted September 9, 2010 Share Posted September 9, 2010 Yea. So $destination_path = "../../../files/123/123/"; // or /home/user/.... cwd gets the current working directory of the script. http://php.net/manual/en/function.getcwd.php Link to comment https://forums.phpfreaks.com/topic/212996-uploading-a-file-to-a-specific-location/#findComment-1109339 Share on other sites More sharing options...
son.of.the.morning Posted September 9, 2010 Share Posted September 9, 2010 try this... <?php // var hoding the path name $path= "upload/".$HTTP_POST_FILES['ufile']['name']; if($ufile !=none) { // copying from the temp folder to your path name if(copy($HTTP_POST_FILES['ufile']['tmp_name'], $path)) { echo "Successful<BR/>"; // display the name, size, type echo "File Name :".$HTTP_POST_FILES['ufile']['name']."<BR/>"; echo "File Size :".$HTTP_POST_FILES['ufile']['size']."<BR/>"; echo "File Type :".$HTTP_POST_FILES['ufile']['type']."<BR/>"; } else { echo "Error"; } } ?> Link to comment https://forums.phpfreaks.com/topic/212996-uploading-a-file-to-a-specific-location/#findComment-1109342 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.