Upload redirection

This is a discussion on "Upload redirection" within the PHP Forum section. This forum, and the thread "Upload redirection are both part of the Program Your Website category.



 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1  
Old Feb 25th, 2007, 13:43
Reputable Member
Join Date: Oct 2006
Location: United Kingdom
Age: 20
Posts: 238
Blog Entries: 6
Thanks: 0
Thanked 0 Times in 0 Posts
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: Select all
<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: Select all
<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: Select all
<?
$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
Last Blog Entry: Blog Noughts and Crosses (Nov 14th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old Feb 25th, 2007, 22:12
Ryan Fait's Avatar
Elite Veteran
Join Date: May 2006
Location: Las Vegas
Posts: 3,787
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?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old Feb 26th, 2007, 08:54
Reputable Member
Join Date: May 2006
Location: Northampton, UK
Posts: 399
Thanks: 0
Thanked 0 Times in 0 Posts
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?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #4  
Old Feb 26th, 2007, 08:59
Reputable Member
Join Date: Oct 2006
Location: United Kingdom
Age: 20
Posts: 238
Blog Entries: 6
Thanks: 0
Thanked 0 Times in 0 Posts
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 Blog Entry: Blog Noughts and Crosses (Nov 14th, 2007)

Last edited by Ross; Feb 26th, 2007 at 09:02.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #5  
Old Feb 26th, 2007, 09:41
Ryan Fait's Avatar
Elite Veteran
Join Date: May 2006
Location: Las Vegas
Posts: 3,787
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #6  
Old Feb 26th, 2007, 13:11
Reputable Member
Join Date: Oct 2006
Location: United Kingdom
Age: 20
Posts: 238
Blog Entries: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Upload redirection

Cheers Ryan, I will give it ago when I get home.
Last Blog Entry: Blog Noughts and Crosses (Nov 14th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #7  
Old Feb 26th, 2007, 21:37
Ryan Fait's Avatar
Elite Veteran
Join Date: May 2006
Location: Las Vegas
Posts: 3,787
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #8  
Old Feb 28th, 2007, 11:29
Reputable Member
Join Date: Oct 2006
Location: United Kingdom
Age: 20
Posts: 238
Blog Entries: 6
Thanks: 0
Thanked 0 Times in 0 Posts
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
Last Blog Entry: Blog Noughts and Crosses (Nov 14th, 2007)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #9  
Old Feb 28th, 2007, 23:32
Ryan Fait's Avatar
Elite Veteran
Join Date: May 2006
Location: Las Vegas
Posts: 3,787
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Upload redirection

Haha, hopefully that won't happen, but if it does, free porn! Woohoo!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Form Redirection madmax PHP Forum 4 Jun 4th, 2007 17:35
Frame redirection with PHP linchpin311 PHP Forum 2 May 17th, 2007 17:35
Site Redirection Maverick25r Web Page Design 2 Oct 6th, 2006 12:33
redirection problem iamzoli PHP Forum 12 Apr 11th, 2004 08:48


All times are GMT. The time now is 06:11.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42