Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem with move_uploaded_file function

Status
Not open for further replies.

TimMontreal

Programmer
Nov 19, 2004
13
CA
Hi,
I'm pretty new to PHP and trying to create a form to upload images to my server (once I master this I will eventually try to upload the image and store their name in MySQL db).

I found some code online that I"m trying to work with which uses a function called "move_uploaded_file", but when I try to upload the file I get the error:
Fatal error: Call to undefined function:  move_uploaded_file() in /home/virtual/site186/fst/var/ on line 12

I checked and my web server is using PHP 4.3.4 and the PHP manual says the function is good for any version after 4.0.3, my code is below , any help would be greatly appreciated:
<?php
//Check that submit has been pressed
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
// directory Path edit with your own
$uploaddir = '/home/corneau/mainwebsite_html/emploi_download/';
for($i=0; $i<count($_FILES['userfile']['tmp_name']); $i++){
// Upload data
$tempname = $_FILES['userfile']['tmp_name'][$i];
$filename = $_FILES['userfile']['name'][$i];
// Move file
if($tempname != ''){
move_uploaded_file($tempname, $uploaddir.$filename);
}
}
print('<pre>');
print_r($_FILES['userfile']['tmp_name']);
print('</pre>');
}
?>
 
ok according to the code above.. the function is not set.. meaning that when you try to call it it is not there to be called. hense the error code

its calling a function that does not exist

The above code only sets the file that you added to the form to some variables, which are then passed to the function that does not exist..

move_uploaded_file($tempname, $uploaddir.$filename);

the function itself is what uploads, and moves the file.

I hope this helps.. I am relativesly new to this also
 
This only should happen when your PHP is really really old. According to the PHP manual move_uploaded_file is available since 4.0.3
If the PHP is really that old, upgrade as soon as you can. If it is a host, stay away from them and find a better one. ;)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top