TutorMe Posted August 31, 2007 Share Posted August 31, 2007 I followed a tutorial in which I ended up with the following code: <? $uploadNeed = $_POST['uploadNeed']; // start for loop for($x=0;$x<$uploadNeed;$x++){ $file_name = $_FILES['uploadFile'. $x]['name']; // strip file_name of slashes $file_name = stripslashes($file_name); $file_name = str_replace("'","",$file_name); $copy = copy($_FILES['uploadFile'. $x]['tmp_name'],$file_name); // check if successfully copied if($copy){ echo "$file_name | uploaded sucessfully!<br>"; }else{ echo "$file_name | could not be uploaded!<br>"; } } // end of loop ?> I am trying to use this code in the directory mysite.com/admin, but I want it to upload files to mysite.com. I just can't seem to find the place to specify the directory. As of now, it uploads to the directory where it is located. Any help would be appreciated. Thanks. Link to comment https://forums.phpfreaks.com/topic/67388-file-upload-path/ Share on other sites More sharing options...
Jessica Posted August 31, 2007 Share Posted August 31, 2007 http://us.php.net/manual/en/function.move-uploaded-file.php Link to comment https://forums.phpfreaks.com/topic/67388-file-upload-path/#findComment-338257 Share on other sites More sharing options...
TutorMe Posted August 31, 2007 Author Share Posted August 31, 2007 Thank you. Link to comment https://forums.phpfreaks.com/topic/67388-file-upload-path/#findComment-338259 Share on other sites More sharing options...
Jessica Posted August 31, 2007 Share Posted August 31, 2007 Welcome. Link to comment https://forums.phpfreaks.com/topic/67388-file-upload-path/#findComment-338263 Share on other sites More sharing options...
TutorMe Posted August 31, 2007 Author Share Posted August 31, 2007 I'm sorry, but I cannot figure out exactly what to do with it. I have added: bool move_uploaded_file ( string $file_name, string $destination ); I tried it in multiple places, but couldn't get it to work. Do you think you could tell me where to put it in my script, and if I'm even using the right syntax? EDIT: I did add the destination variable: $destination = "../uploads" Link to comment https://forums.phpfreaks.com/topic/67388-file-upload-path/#findComment-338273 Share on other sites More sharing options...
Fadion Posted August 31, 2007 Share Posted August 31, 2007 <?php if(move_uploaded_file($_FILES['uploadFile'. $x]['tmp_name'], $destination)){ echo 'File uploaded succesfully'; } else{ echo 'Did not upload'; } ?> And yep it should work with relative paths '../'. Link to comment https://forums.phpfreaks.com/topic/67388-file-upload-path/#findComment-338321 Share on other sites More sharing options...
Jessica Posted August 31, 2007 Share Posted August 31, 2007 You just copied and pasted the docs. You didn't actually write new code. bool is what type it returns, strings are what you send it. You don't just C&P without understanding Link to comment https://forums.phpfreaks.com/topic/67388-file-upload-path/#findComment-338322 Share on other sites More sharing options...
phpSensei Posted August 31, 2007 Share Posted August 31, 2007 http://w3schools.com/php/php_file_upload.asp << use it... Link to comment https://forums.phpfreaks.com/topic/67388-file-upload-path/#findComment-338323 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.