FTP Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsSystem AdministrationFTP Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 15th, 2002, 09:07 PM
steveup steveup is offline
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Location: Newfoundland, Canada
Posts: 30 steveup User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 m 39 sec
Reputation Power: 7
File uploads or FTP --- mental block

Hello, here's my situation:
User fills out a bunch of form fields, browses local HD and select a file then submits it.

I want to upload that file to the webserver, with the results of the form inserted into the beginning of the file (just plain text, before the rest of the file from users HD)

I can upload the file to the server and open the temporary file (form post result) --- this is not my problem. I cannot move or copy uploaded file from the temp space to my desired directory because of "permission denied". BTW I am using php on IIS.....

How can I upload this file via PHP or FTP with a little bit of info prepended to it?

Anyone have any suggestions? My explanation of the scenario suck and want to know more? Post here.

Thanks All
Steve

Last edited by steveup : October 15th, 2002 at 09:11 PM.

Reply With Quote
  #2  
Old October 15th, 2002, 09:26 PM
steveup steveup is offline
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Location: Newfoundland, Canada
Posts: 30 steveup User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 m 39 sec
Reputation Power: 7
http://www.php.net/manual/en/function.fopen.php


This is my best bet using the FTP option -- it looks like it may save me, although it seems when I open a new file for writing on the server, it is not created.....

Thanks.

Steve

Last edited by steveup : October 16th, 2002 at 11:21 AM.

Reply With Quote
  #3  
Old October 15th, 2002, 09:27 PM
AlCapone's Avatar
AlCapone AlCapone is offline
Mobbing Gangster
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Sep 2001
Location: "Best City" 2002 and 2003- Melbourne, Australia
Posts: 4,913 AlCapone User rank is Sergeant (500 - 2000 Reputation Level)AlCapone User rank is Sergeant (500 - 2000 Reputation Level)AlCapone User rank is Sergeant (500 - 2000 Reputation Level)AlCapone User rank is Sergeant (500 - 2000 Reputation Level)AlCapone User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 5 h 36 m 31 sec
Reputation Power: 17
Send a message via ICQ to AlCapone Send a message via AIM to AlCapone Send a message via Yahoo to AlCapone
>>I cannot move or copy uploaded file from the temp space to my desired directory
On your http server or on remote ftp server?

Generally what you need to do is first get file from user using http upload, then get your info from form into a var, open blank file, write that var in there, open uploaded file, read text from there and put it in new file then upload new file in ascii mode and delete both files at the end.
__________________
And you know I mean that.

Reply With Quote
  #4  
Old October 15th, 2002, 09:28 PM
Adman's Avatar
Adman Adman is offline
PHP Programmer
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Posts: 45 Adman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 58 m 7 sec
Reputation Power: 7
if safe_mode is on in php.ini(not sure if this is where it is, but I would assume it is there), you need to use move_uploaded_file() instead of copy()
__________________
//Adman

Reply With Quote
  #5  
Old October 15th, 2002, 09:31 PM
steveup steveup is offline
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2002
Location: Newfoundland, Canada
Posts: 30 steveup User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 m 39 sec
Reputation Power: 7
What you are saying makes sense and is how I planned to do it, but how do I open this blank temp file? Opening (touching) one remotely isnt an option - can I make a "pretend" temp file locally, which would be a result of the form and the userfile somehow, then upload that using ftp? Or maybe sleep is what I need.....

Thanks

Steve

Reply With Quote
  #6  
Old October 15th, 2002, 09:34 PM
Adman's Avatar
Adman Adman is offline
PHP Programmer
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Posts: 45 Adman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 58 m 7 sec
Reputation Power: 7
ftp should not be needed.

Reply With Quote
  #7  
Old October 15th, 2002, 09:38 PM
AlCapone's Avatar
AlCapone AlCapone is offline
Mobbing Gangster
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Sep 2001
Location: "Best City" 2002 and 2003- Melbourne, Australia
Posts: 4,913 AlCapone User rank is Sergeant (500 - 2000 Reputation Level)AlCapone User rank is Sergeant (500 - 2000 Reputation Level)AlCapone User rank is Sergeant (500 - 2000 Reputation Level)AlCapone User rank is Sergeant (500 - 2000 Reputation Level)AlCapone User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 5 h 36 m 31 sec
Reputation Power: 17
Send a message via ICQ to AlCapone Send a message via AIM to AlCapone Send a message via Yahoo to AlCapone
Hold up, here's what I gathered from original post - steveup wants users to upload ascii file from their hdd to his server, put some info from form in the beginning of file (may be name/date?) and then upload it to remote ftp server for storage or public access. How far am I off on this one?

Reply With Quote
  #8  
Old October 15th, 2002, 09:41 PM
Adman's Avatar
Adman Adman is offline
PHP Programmer
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Posts: 45 Adman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 58 m 7 sec
Reputation Power: 7
PHP Code:
 $fp fopen($HTTP_POST_FILES['forminputname']['tmp_name'], "w+");
$Contents fread($fpfilesize($HTTP_POST_FILES['forminputname']['tmp_name']);
frwrite($fp$WhatToAdd.$Contents); 


Just a shot in the dark.

Reply With Quote
  #9  
Old October 15th, 2002, 09:56 PM
AlCapone's Avatar
AlCapone AlCapone is offline
Mobbing Gangster
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Sep 2001
Location: "Best City" 2002 and 2003- Melbourne, Australia
Posts: 4,913 AlCapone User rank is Sergeant (500 - 2000 Reputation Level)AlCapone User rank is Sergeant (500 - 2000 Reputation Level)AlCapone User rank is Sergeant (500 - 2000 Reputation Level)AlCapone User rank is Sergeant (500 - 2000 Reputation Level)AlCapone User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 5 h 36 m 31 sec
Reputation Power: 17
Send a message via ICQ to AlCapone Send a message via AIM to AlCapone Send a message via Yahoo to AlCapone
Good logic, adman, but flaw in the code. w+ erases all the content as soon as file is opened.

Reply With Quote
  #10  
Old October 15th, 2002, 10:01 PM
Adman's Avatar
Adman Adman is offline
PHP Programmer
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Posts: 45 Adman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 58 m 7 sec
Reputation Power: 7
then you would open if for appending instead.

Reply With Quote
  #11  
Old October 15th, 2002, 10:03 PM
AlCapone's Avatar
AlCapone AlCapone is offline
Mobbing Gangster
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Sep 2001
Location: "Best City" 2002 and 2003- Melbourne, Australia
Posts: 4,913 AlCapone User rank is Sergeant (500 - 2000 Reputation Level)AlCapone User rank is Sergeant (500 - 2000 Reputation Level)AlCapone User rank is Sergeant (500 - 2000 Reputation Level)AlCapone User rank is Sergeant (500 - 2000 Reputation Level)AlCapone User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 5 h 36 m 31 sec
Reputation Power: 17
Send a message via ICQ to AlCapone Send a message via AIM to AlCapone Send a message via Yahoo to AlCapone
>>then you would open if for appending instead.
...which means adding info to the end rather then beginning, and we don't want that.

steveup, could your describe what you want to do one more time?

Reply With Quote
  #12  
Old October 15th, 2002, 10:07 PM
Adman's Avatar
Adman Adman is offline
PHP Programmer
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Posts: 45 Adman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 58 m 7 sec
Reputation Power: 7
PHP Code:
 $fp fopen($HTTP_POST_FILES['forminputname']['tmp_name'], "r");
$Contents fread($fpfilesize($HTTP_POST_FILES['forminputname']['tmp_name']);
flcose($fp);

$fp fopen($HTTP_POST_FILES['forminputname']['tmp_name'], "w");
fwrite($fp$WhatToAdd.$Contents);
fclose($fp); 


How does that look Al

Last edited by Adman : October 15th, 2002 at 10:16 PM.

Reply With Quote
  #13  
Old October 15th, 2002, 10:14 PM
AlCapone's Avatar
AlCapone AlCapone is offline
Mobbing Gangster
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Sep 2001
Location: "Best City" 2002 and 2003- Melbourne, Australia
Posts: 4,913 AlCapone User rank is Sergeant (500 - 2000 Reputation Level)AlCapone User rank is Sergeant (500 - 2000 Reputation Level)AlCapone User rank is Sergeant (500 - 2000 Reputation Level)AlCapone User rank is Sergeant (500 - 2000 Reputation Level)AlCapone User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 5 h 36 m 31 sec
Reputation Power: 17
Send a message via ICQ to AlCapone Send a message via AIM to AlCapone Send a message via Yahoo to AlCapone
almost there - other then the fact you're opening it for reading both times and missing =

Reply With Quote
  #14  
Old October 15th, 2002, 10:17 PM
Adman's Avatar
Adman Adman is offline
PHP Programmer
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Posts: 45 Adman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 58 m 7 sec
Reputation Power: 7
Edited

Reply With Quote
  #15  
Old October 15th, 2002, 10:21 PM
AlCapone's Avatar
AlCapone AlCapone is offline
Mobbing Gangster
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Sep 2001
Location: "Best City" 2002 and 2003- Melbourne, Australia
Posts: 4,913 AlCapone User rank is Sergeant (500 - 2000 Reputation Level)AlCapone User rank is Sergeant (500 - 2000 Reputation Level)AlCapone User rank is Sergeant (500 - 2000 Reputation Level)AlCapone User rank is Sergeant (500 - 2000 Reputation Level)AlCapone User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 5 h 36 m 31 sec
Reputation Power: 17
Send a message via ICQ to AlCapone Send a message via AIM to AlCapone Send a message via Yahoo to AlCapone
I don't think he wants to keep that file in /tmp, so why don't you make it read from tmp_name but write to /home/whatever

Reply With Quote