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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.