biwerw Posted May 6, 2009 Share Posted May 6, 2009 I'm using the following script to upload files. I can not figure out how to change the directory... The folder is called "lgl-up" and is inside the folder where the script is located. I tried using chdir but couldn't get it to work correctly. <?php // Edit upload location here $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; } sleep(1); ?> <script language="javascript" type="text/javascript">window.top.window.stopUpload(<?php echo $result; ?>);</script> Any help appreciated. Thanks. Link to comment https://forums.phpfreaks.com/topic/157124-solved-upload-script-directory-change/ Share on other sites More sharing options...
w3evolutions Posted May 6, 2009 Share Posted May 6, 2009 If you are trying to upload to the same directroy or a derectory below the current php file you are in you can just use it's name: // Edit upload location here $result = 0; $target_path = getcwd()."/lgl-up/". basename( $_FILES['myfile']['name']); // This can also just be "lgl-up/" . basename( $_FILES['myfile']['name']); if(@move_uploaded_file($_FILES['myfile']['tmp_name'], $target_path)) { $result = 1; } sleep(1); try that. Link to comment https://forums.phpfreaks.com/topic/157124-solved-upload-script-directory-change/#findComment-827845 Share on other sites More sharing options...
biwerw Posted May 6, 2009 Author Share Posted May 6, 2009 That worked great, thanks. Link to comment https://forums.phpfreaks.com/topic/157124-solved-upload-script-directory-change/#findComment-827923 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.