|
|
 |
February 25th, 2007, 10:43 AM
|
#1
|
|
Reputable Member
Join Date: Oct 2006
Location: United Kingdom
Age: 22
Posts: 238
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0
|
Upload redirection
Hi,
Basically I am using a very basic upload script, so that a friend can upload to my server. I have protected the script by a simple .htaccess file.
The code I am using is as follow: -
Number of upload holders
Code:
<title>Upload</title>
<html>
<head>
<title># of Files to Upload</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form name="form1" method="post" action="uploadForm2.php">
<p>Enter the amount of boxes you will need below. Max = 5.</p>
<p>
<input name="uploadNeed" type="text" id="uploadNeed" maxlength="1">
</p>
<p>
<input type="submit" name="Submit" value="Submit">
</p>
</form>
</body>
</html>
File selector
Code:
<title>Upload</title>
<html>
<head>
<title># of Files to Upload</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<form name="form1" method="post" action="uploadForm2.php">
<p>Enter the amount of boxes you will need below. Max = 5.</p>
<p>
<input name="uploadNeed" type="text" id="uploadNeed" maxlength="1">
</p>
<p>
<input type="submit" name="Submit" value="Submit">
</p>
</form>
</body>
</html>
Processing file
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
?>
Is there anyway of redirecting the uploaded file to another file, rather than the directory that stores the . php upload script?
Edit :- Sorry I just noticed this is in the wrong forum
Thanks in advance,
Ross
|
|
|
February 25th, 2007, 07:12 PM
|
#2
|
|
Elite Veteran
Join Date: May 2006
Location: Las Vegas
Posts: 3,784
Thanks: 0
Thanked 0 Times in 0 Posts
|
Re: Upload redirection
Moved to the PHP forum for you. I'm a little confused. What do you mean by "redirecting the uploaded file to another file?" Like overwriting?
|
|
|
February 26th, 2007, 05:54 AM
|
#3
|
|
Reputable Member
Join Date: May 2006
Location: Warrington, UK
Posts: 440
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0
|
Re: Upload redirection
When you first upload a file using php, it is automatically stored in a temp directory within your directory structure.
However, it cant really be used form this location, so it is normal to "move" the file to a permanent storage location, and in some cases re-name it at the same time.
Is this what your looking to do?
|
|
|
February 26th, 2007, 05:59 AM
|
#4
|
|
Reputable Member
Join Date: Oct 2006
Location: United Kingdom
Age: 22
Posts: 238
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0
|
Re: Upload redirection
Hi, thanks for your replies.
I just read it back, and it's not clear at all ha.
Basically,
The upload script would be in on my server
/file/file2
but I was wondering if it would be possible to send the file to
/file1/
On my server because I need to keep the upload area secured but I need the files to be moved into a different file as they will be linked up to be downloaded.
Thanks,
Ross
Last edited by Ross; February 26th, 2007 at 06:02 AM..
|
|
|
February 26th, 2007, 06:41 AM
|
#5
|
|
Elite Veteran
Join Date: May 2006
Location: Las Vegas
Posts: 3,784
Thanks: 0
Thanked 0 Times in 0 Posts
|
Re: Upload redirection
Yeah, that's possible. I would recommend using the FTP uploading functions, though. They're much easier to use and you don't need to worry about chmod settings and temporary files.
http://php.net/ftp
|
|
|
February 26th, 2007, 10:11 AM
|
#6
|
|
Reputable Member
Join Date: Oct 2006
Location: United Kingdom
Age: 22
Posts: 238
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0
|
Re: Upload redirection
Cheers Ryan, I will give it ago when I get home.
|
|
|
February 26th, 2007, 06:37 PM
|
#7
|
|
Elite Veteran
Join Date: May 2006
Location: Las Vegas
Posts: 3,784
Thanks: 0
Thanked 0 Times in 0 Posts
|
Re: Upload redirection
Oh, specifically ftp_put.
http://us2.php.net/manual/en/function.ftp-put.php
There's a nice example there 
|
|
|
February 28th, 2007, 08:29 AM
|
#8
|
|
Reputable Member
Join Date: Oct 2006
Location: United Kingdom
Age: 22
Posts: 238
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0
|
Re: Upload redirection
Thanks Ryan for those, I haven't got around to trying them yet, but I will post when I get it working (and someone hijacks my server due to it and stores porn on it, because I mucked it up  ).
Have a great day,
Ross
|
|
|
February 28th, 2007, 08:32 PM
|
#9
|
|
Elite Veteran
Join Date: May 2006
Location: Las Vegas
Posts: 3,784
Thanks: 0
Thanked 0 Times in 0 Posts
|
Re: Upload redirection
Haha, hopefully that won't happen, but if it does, free porn! Woohoo!
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|