|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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. |
|
#2
|
|||
|
|||
|
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. |
|
#3
|
||||
|
||||
|
>>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. |
|
#4
|
||||
|
||||
|
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 |
|
#5
|
|||
|
|||
|
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 |
|
#6
|
||||
|
||||
|
ftp should not be needed.
|
|
#7
|
||||
|
||||
|
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?
|
|
#8
|
||||
|
||||
|
PHP Code:
Just a shot in the dark. |
|
#9
|
||||
|
||||
|
Good logic, adman, but flaw in the code. w+ erases all the content as soon as file is opened.
|
|
#10
|
||||
|
||||
|
then you would open if for appending instead.
|
|
#11
|
||||
|
||||
|
>>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? |
|
#12
|
||||
|
||||
|
PHP Code:
How does that look Al ![]() Last edited by Adman : October 15th, 2002 at 10:16 PM. |
|
#13
|
||||
|
||||
|
almost there - other then the fact you're opening it for reading both times and missing =
![]() |
|
#14
|
||||
|
||||
|
Edited
|
|
#15
|
||||
|
||||
|
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
|