|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
FTP upload script errors
I've been working on making a script to upload image files to the server through a PHP script. I have 2 files: images.html (which is the upload form), and image_manager.php (which uploads the image file thru FTP). I've been going through the code for an hour, and still can't figure out my errors. It has something to do with my $connect variable.
Here's the errors I'm getting: Warning: ftp_login() expects parameter 1 to be resource, string given in /usr/home/hostultra/hostultra.com/html/hosted/sites/Mobius_Man/image_manager.php on line 18 Warning: ftp_mkdir() expects parameter 1 to be resource, string given in /usr/home/hostultra/hostultra.com/html/hosted/sites/Mobius_Man/image_manager.php on line 24 Warning: ftp_chdir() expects parameter 1 to be resource, string given in /usr/home/hostultra/hostultra.com/html/hosted/sites/Mobius_Man/image_manager.php on line 25 uploaded! Warning: ftp_close() expects parameter 1 to be resource, string given in /usr/home/hostultra/hostultra.com/html/hosted/sites/Mobius_Man/image_manager.php on line 50 And here's my script: PHP Code:
|
|
#2
|
||||
|
||||
|
Read: http://www.php.net/manual/en/ref.ftp.php
You need to send a connection id(or connection resource) to the ftp functions. |
|
#3
|
|||
|
|||
|
Why are you putting the function call in quotes.
ie. //variable that connects to the FTP server $connect="ftp_connect(ftp.hostultra.com, 21, 120)"; s/b $connect = ftp_connect('ftp.hostultra.com',21,120); ... all the way down |
|
#4
|
||||
|
||||
|
Well, I changed that stuff, however it still isn't working. But, now I only get these errors:
Warning: ftp_mkdir() expects parameter 1 to be resource, string given in /usr/home/hostultra/hostultra.com/html/hosted/sites/Mobius_Man/image_manager.php on line 24 Warning: ftp_chdir() expects parameter 1 to be resource, string given in /usr/home/hostultra/hostultra.com/html/hosted/sites/Mobius_Man/image_manager.php on line 25 Warning: ftp_put(): error opening in /usr/home/hostultra/hostultra.com/html/hosted/sites/Mobius_Man/image_manager.php on line 36 Upload of was unsuccessful! Here's the form code: Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Image Upload</title>
</head>
<script language="JavaScript">
function insertImage(imgPath)
{
parent.opener.iView.focus();
parent.window.close();
parent.opener.iView.document.execCommand('insertimage', false, imgPath);
}
</script>
<body>
<form action="image_manager.php" method="post" enctype="multipart/form-data">
<input type="hidden" name="doUpload" value="true">
<div class="text">Upload File:</div>
<input type="file" name="source_file"> <input type="submit" value="Upload" onClick="this.value='Please Wait...'">
</form>
</body>
</html>
PHP Code:
Oh the joys of trying to learn PHP... ![]() |
|
#5
|
|||
|
|||
|
Quote:
Well it's the same problem.. when you put variables in quotes they have became literals, so instead of passing your connectionid you are passing a string '$connectionid' to the function... which it hates. |
|
#6
|
|||
|
|||
|
I am getting upload one image in php and check if upload is successful, however, when the script finish for close the connection ftp, I receive this error: Fatal error: Call to undefined function: ftp_close() in c:\apache\htdocs\test.php on line 11
I am using ftp_close($conn_id); for close the $conn_id connection. Can you tell me what is happening? |
![]() |
| Viewing: Dev Shed Forums > System Administration > FTP Help > FTP upload script errors |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|