I have this problem when trying to upload multiple files to a ftp-server. Basically I have one page post to $_POST a list of local files, and in the fileupload.php, I connect to the server, and can upload the first file in the array just fine. Everything else I receive an error about the file can't be found.
Im doing something like ** note psuedo code **
(for i = 0; i < file_count; i++)
{
fp = fopen(file_array)
if (!fp)
print "file loading error"; continue;
ftp_fput(con_stream, filename_dest, fp, ftp_binary);
fclose(fp);
}
I know i'm getting the right file name, maybe there is something I don't know about how html encodes files into a page?
Multiple File Uploading with php_ftp(functions)
Moderator: General Moderators
-
allan20850
- Forum Newbie
- Posts: 4
- Joined: Wed Jun 15, 2005 8:31 am
Code: Select all
tags want to smile around your code you all day long, today.
http://forums.devnetwork.net/viewtopic.php?t=21171-
allan20850
- Forum Newbie
- Posts: 4
- Joined: Wed Jun 15, 2005 8:31 am
real code
This is the bulk of my problem, if I can get this to work, then i should be able to implement what i need to do.
$num, and $list are both already decleared and i've verified that they do contain what i need them to be.
$list is an array of file names containing the path.
ie 'C:\\temp\\filename.txt'
$num is the number of files in the array.
Code: Select all
for ($i = 0; $i < $num; $i++)
{
$fp[$i] = fopen($list[$i],"rb",true);
if ($fp)
print "file loaded<br>";
else
print "error<br>";
}$list is an array of file names containing the path.
ie 'C:\\temp\\filename.txt'
$num is the number of files in the array.
-
allan20850
- Forum Newbie
- Posts: 4
- Joined: Wed Jun 15, 2005 8:31 am
so confused.
So if I do something like this
That works, and when I use cuteftp to look at the files in the server, they both appear, f1 & f2. So why can't I do this in a for-loop?
Code: Select all
$fp1 = fopen("C:\\temp\\file1.tmp","rb",true");
$fp2 = fopen("C:\\temp\\file2.tmp","rb",true");
ftp_fput($con_id,"f1",$fp1, FTP_BINARY);
ftp_fput($con_id,"f2",$fp2, FTP_BINARY);-
allan20850
- Forum Newbie
- Posts: 4
- Joined: Wed Jun 15, 2005 8:31 am
problem found
Found the problem. Basically whatever I did to the array when I built it from the previous page (which was made via a javascript), it added a whitespace (of which I don't know, nor do I care to go back and edit out which of the \n\t\0\r\x0 to find which one it is) and thats what was causing the fopen not to be able to find the file.