Jump to content

File upload path.


TutorMe

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.