TimMontreal
Programmer
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>');
}
?>
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>');
}
?>