hi friends .. i need help i have a simple script to upload files to server : $yourdomain = 'http://domain.com/'; $uploaddir = 'dl/'; $filename = $_FILES['file']['name']; $filesize = $_FILES['file']['size']; $tmpname_file = $_FILES['file']['tmp_name']; $date_file = date(imdy); if($filesize > '900000000000') { echo "Way too big!!"; } else { move_uploaded_file($tmpname_file, "$uploaddir$date_file$filename"); echo "<br /><br><br>Download Link: <font color=blue><a href=".$yourdomain.$uploaddir.$date_file.$filename.">".$yourdomain.$uploaddir.$date_file.$filename."</font></a>"; } it upload file to "/dl/" and rename the file name to 972839753myfile.zip i need to make it domain.com/dl/353465786/myfile.zip plz help
Two approaches. You can handle this with a rewrite rule. I'm not good enough at writing rewrite rules to help you with this, but something that sees requests to /dl/* and points them to the appropriate file could work. Otherwise, http://us.php.net/mkdir
$yourdomain = 'domain.com/'; #remove protocol so that we can use it as dir $uploaddir = "/$domain/dl/"; . . . if($filesize > '900000000000') { echo "Way too big!!"; } else { move_uploaded_file($tmpname_file, "{$uploaddir}{$date_file$filename}"); #etc etc } PHP: I hope this will work if you have enough permissions to write to said folder.
Hi, lt's make it more compact and simple @mkdir("domain.com/dl/{$date_file}"); #create directory if missing $uploaddir = "domain.com/dl/{$date_file}"; # is this the folder you want to write files to ? move_uploaded_file($tmpname_file, "{$uploaddir}/{$filename}"); #upload file to desired directory PHP: Is it clear now?
You'll need to post your entire code for us to review. Vooler's example wasn't a complete solution, it was a snippet to get you pointed in the right direction.
Be sure your problems with this aren't related to permissions. The code may work, but you need the right file permissions set for it to work correctly. Also, just so you know, file uploads aren't the easiest tasks for beginners. But, it isn't that bad if you spend a little time with it.
$yourdomain = 'http://www.ougfiles.in/'; $uploaddir = 'dl/'; $filename = $_FILES['file']['name']; $filesize = $_FILES['file']['size']; $tmpname_file = $_FILES['file']['tmp_name']; $date_file = date(imdy); @mkdir("$uploaddir$date_file"); if($filesize > '900000000000') { echo "Way too big!!"; } else { move_uploaded_file($tmpname_file, "$uploaddir$date_file/$filename"); echo "<br /><br><br>Download Link: <font color=blue><a href=".$yourdomain.$uploaddir.$date_file.'/'.$filename.">".$yourdomain.$uploaddir.$date_file.$filename."</font></a>"; } PHP: