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 Quote Link to comment 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/ Quote Link to comment 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? Quote Link to comment 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 Quote Link to comment 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"; } } ?> Quote Link to comment 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.