iEntry 10th Anniversary Webforumz RegistrationAnnouncements Contact Webforumz StaffContact
Home Resources Blogs Meet the Team Contact Register
 

Go Back   WebForumz.com > The Code > PHP

Reply
 
LinkBack Thread Tools
Old February 25th, 2007, 10:43 AM   #1
Reputable Member
 

Join Date: Oct 2006
Location: United Kingdom
Age: 22
Posts: 238
Blog Entries: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 Ross will become famous soon enough
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
Ross is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old February 25th, 2007, 07:12 PM   #2
Elite Veteran
 
Ryan Fait's Avatar
 

Join Date: May 2006
Location: Las Vegas
Posts: 3,784
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 Ryan Fait is a jewel in the rough Ryan Fait is a jewel in the rough Ryan Fait is a jewel in the rough Ryan Fait is a jewel in the rough
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?
Ryan Fait is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old 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 Accurax is on a distinguished road
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?
Accurax is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old February 26th, 2007, 05:59 AM   #4
Reputable Member
 

Join Date: Oct 2006
Location: United Kingdom
Age: 22
Posts: 238
Blog Entries: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 Ross will become famous soon enough
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..
Ross is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old February 26th, 2007, 06:41 AM   #5
Elite Veteran
 
Ryan Fait's Avatar
 

Join Date: May 2006
Location: Las Vegas
Posts: 3,784
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 Ryan Fait is a jewel in the rough Ryan Fait is a jewel in the rough Ryan Fait is a jewel in the rough Ryan Fait is a jewel in the rough
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
Ryan Fait is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old February 26th, 2007, 10:11 AM   #6
Reputable Member
 

Join Date: Oct 2006
Location: United Kingdom
Age: 22
Posts: 238
Blog Entries: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 Ross will become famous soon enough
Re: Upload redirection

Cheers Ryan, I will give it ago when I get home.
Ross is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old February 26th, 2007, 06:37 PM   #7
Elite Veteran
 
Ryan Fait's Avatar
 

Join Date: May 2006
Location: Las Vegas
Posts: 3,784
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 Ryan Fait is a jewel in the rough Ryan Fait is a jewel in the rough Ryan Fait is a jewel in the rough Ryan Fait is a jewel in the rough
Re: Upload redirection

Oh, specifically ftp_put.

http://us2.php.net/manual/en/function.ftp-put.php

There's a nice example there
Ryan Fait is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old February 28th, 2007, 08:29 AM   #8
Reputable Member
 

Join Date: Oct 2006
Location: United Kingdom
Age: 22
Posts: 238
Blog Entries: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 Ross will become famous soon enough
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
Ross is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Old February 28th, 2007, 08:32 PM   #9
Elite Veteran
 
Ryan Fait's Avatar
 

Join Date: May 2006
Location: Las Vegas
Posts: 3,784
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Altering Power: 0 Ryan Fait is a jewel in the rough Ryan Fait is a jewel in the rough Ryan Fait is a jewel in the rough Ryan Fait is a jewel in the rough
Re: Upload redirection

Haha, hopefully that won't happen, but if it does, free porn! Woohoo!
Ryan Fait is offline  
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

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 4 June 4th, 2007 02:35 PM
Frame redirection with PHP linchpin311 PHP 2 May 17th, 2007 02:35 PM
Site Redirection Maverick25r HTML, XHTML and CSS 2 October 6th, 2006 09:33 AM
redirection problem iamzoli PHP 12 April 11th, 2004 05:48 AM


Search Engine Optimization by vBSEO 3.2.0 RC8