Jump to content

Uploading a file to a specific location


shanejones

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/212996-uploading-a-file-to-a-specific-location/
Share on other sites

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";
}
}
?>

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.