Advanced URL upload

Started on the old forum in April 2012 · view the original in the archive · old links redirect here

7 replies · 1,058 views · started 14 years ago · 1 min read

4 participants
KingofKingZ Junior · 20 posts #1

Hy !!! using url upload is it possible to make the file to be placed on our desired directory?

like

when we do url upload

make the file to be uploaded on this folder

/games/symbian

another example

instead of getting the file on the same folder where the url uploader script is present if iam running the urluploader script in "UPLOAD" folder (for example)

can i make it get uploaded in videos folder ( i mean the uploaded file ) i hope you can understand what i am trying to say !!

One more thing !! there are scripts which will make them to get uploaded like the way i described i want mp4 files to be uploaded on videos/mp4

and 3gp files to be uploaded on videos/3gp

[ sorry for bad english]

Loony Senior · 258 posts #2

here

<?php

if($_POST["submit"]){
$url = trim($_POST["url"]);
if($url){
$file = fopen($url,"rb");
if($file){
$filename = strtolower($file) ; 
 $exts = split("[/\\.]", $filename) ; 
 $n = count($exts)-1; 
 $exts = $exts[$n]; 
 return $exts; 
 if($exts=="mp4"){
$directory = "videos/mp4";
}
if($exts=="3gp"){
$directory = "videos/3gp";
}else{
$directory = "./downloads";
}

$valid_exts = array("jpg","jpeg","gif","png","mp4","3gp"); 
$ext = end(explode(".",strtolower(basename($url))));
if(in_array($ext,$valid_exts)){
$rand = rand(10000,99999);
$filename = $rand . basename($url);
$newfile = fopen($directory . $filename, "wb"); 
if($newfile){
while(!feof($file)){
// Write the url file to the directory.
fwrite($newfile,fread($file,1024 * 8),1024 * 8);
}
echo 'File uploaded successfully! You can access the file here:'."\n";
echo ''.$directory.$filename.'';
} else { echo 'Could not establish new file ('.$directory.$filename.') on local server. Be sure to CHMOD your directory to 777.'; }
} else { echo 'Invalid file type. Please try another file.'; }
} else { echo 'Could not locate the file: '.$url.''; }
} else { echo 'Invalid URL entered. Please try again.'; }
}
?>

edited to suit request

you will need to add more checks also this is completety unchecked so u will have to fix errors and what not

Creator of Epix.Mobi

Keep an Eye on us Big things coming soon!!!! Need something for your site hit me up here http://coding-talk.com/forum/main-forums/marketplace/153110-free-features-for-your-wapsite

KingofKingZ Junior · 20 posts #3

should i just run it or what? when i ran it nothing happened !!! can u pls tell me where should i upload this script? should i make a new folder for this in public_html and what is the chmod for this?

Loony Senior · 258 posts #6

ok

  1. create a folder called upload
  2. create a file in that folder called index.php 3.copy your sites headers and footers and add
<form action="upload.php" method="post">
Enter URL: <input type="text" name="url" size="35" /> <input type="submit" value="Submit" name="submit" />
</form>

to the index.php file

4.create a file called upload.php 5.copy your sites headers and footers and add

<?php 

if($_POST["submit"]){ 
$url = trim($_POST["url"]); 
if($url){ 
$file = fopen($url,"rb"); 
if($file){ 
$filename = strtolower($file) ;  
 $exts = split("[/\\.]", $filename) ;  
 $n = count($exts)-1;  
 $exts = $exts[$n];  
 return $exts;  
 if($exts=="mp4"){ 
$directory = "videos/mp4"; 
} 
if($exts=="3gp"){ 
$directory = "videos/3gp"; 
}else{ 
$directory = "downloads"; 
} 

$valid_exts = array("jpg","jpeg","gif","png","mp4","3gp");  
$ext = end(explode(".",strtolower(basename($url)))); 
if(in_array($ext,$valid_exts)){ 
$rand = rand(10000,99999); 
$filename = $rand . basename($url); 
$newfile = fopen($directory . $filename, "wb");  
if($newfile){ 
while(!feof($file)){ 
// Write the url file to the directory. 
fwrite($newfile,fread($file,1024 * 8),1024 * 8); 
} 
echo 'File uploaded successfully! You can access the file here:'."\n"; 
echo ''.$directory.$filename.''; 
} else { echo 'Could not establish new file ('.$directory.$filename.') on local server. Be sure to CHMOD your directory to 777.'; } 
} else { echo 'Invalid file type. Please try another file.'; } 
} else { echo 'Could not locate the file: '.$url.''; } 
} else { echo 'Invalid URL entered. Please try again.'; } 
} 
?>

to your upload.php file

  1. create 2 folders called downloads and 1 videos
  2. chmod those 2 folders to 777
  3. inside the videos folder create 2 more folders 1 called mp4 and the other called 3gp 9.chmod those 2 folders to 777

then the rest is up to you mate ive almost done it all for you anyway

Creator of Epix.Mobi

Keep an Eye on us Big things coming soon!!!! Need something for your site hit me up here http://coding-talk.com/forum/main-forums/marketplace/153110-free-features-for-your-wapsite

EpIcInCoGnItO Developer · 53 posts #7

Thank Loony mate, this will help alot. Thanks for the codes.

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close