bluewalrus
11-05-2009, 02:18 AM
Can anyone see anything wrong here? This was working before, I changed the max upload size, post max size, and the memory limit because the max size was cutting it off. I changed somethings around before I figured out I had to restart the php to get the new php.ini running. Thanks for anything you can see wrong here.
<?php
echo basename($_FILES['uploadfile']['name']);
// get the address of page
$url = $_SERVER['REQUEST_URI'];
//from the address get the article id
$page = explode ("/test/php/jquery/upload-file.php?id=", $url);
//set the id to a variable
$id_is = $page[1];
//If we didn't get and id assume directory was entered with a lowercase r
if (($id_is === "") || !isset($id_is) || empty($id_is)) {
$url = explode ("/Test/php/jquery/upload-file.php?id=", $url);
$id_is = $url[1];
}
// set the directory for where the file file is to go
$uploaddir = "./../../../files/ftp_upload/$id_is/";
//set the file name for the email
//$file_name = basename($_FILES['uploadfile']['name']);
//set the path and file name for the move file
$file = $uploaddir . basename($_FILES['uploadfile']['name']);
echo $file . "\n" . $uploaddir . "\n";
//Directory exisits start to put file there
// put the temporary file in the permanent location
if (move_uploaded_file($_FILES['uploadfile']['tmp_name'], $file)) {
echo "Success";
// set the date and time when the file finished transfering for the email
//$now = date('l\, F jS\, Y \a\t H:i:s');
// send the email
//$to = "me@me.com";
//$subject = "File Uploaded";
//$file_type = $_POST['upload_type'];
//$message = "The file $file_name was uploaded to article $id_is on $now. $file_is type is $type form is set $it_is";
//$from = "From:mw@me.com";
//mail($to, $subject, $message, $from);
//if there was a problem putting the temporary file in the permanent location
}
else
{
echo "error ".$_FILES['uploadfile']['error']." --- ".$_FILES['uploadfile']['tmp_name']." %%% ".$file."($size)";
}
?>
The file input name is "uploadfile", I think it might be the domain structuring but I'm not sure. The domain is like this http://www.mydomain.com/test/php/jquery/upload-file.php?id=1234. I'm trying to put the file in http://www.mydomain.com/files/ftp_upload/1234/
This is what I get for an output
./../../../files/ftp_upload/1234/
./../../../files/ftp_upload/1234/
error --- %%% ./../../../files/ftp_upload/1234/()
<?php
echo basename($_FILES['uploadfile']['name']);
// get the address of page
$url = $_SERVER['REQUEST_URI'];
//from the address get the article id
$page = explode ("/test/php/jquery/upload-file.php?id=", $url);
//set the id to a variable
$id_is = $page[1];
//If we didn't get and id assume directory was entered with a lowercase r
if (($id_is === "") || !isset($id_is) || empty($id_is)) {
$url = explode ("/Test/php/jquery/upload-file.php?id=", $url);
$id_is = $url[1];
}
// set the directory for where the file file is to go
$uploaddir = "./../../../files/ftp_upload/$id_is/";
//set the file name for the email
//$file_name = basename($_FILES['uploadfile']['name']);
//set the path and file name for the move file
$file = $uploaddir . basename($_FILES['uploadfile']['name']);
echo $file . "\n" . $uploaddir . "\n";
//Directory exisits start to put file there
// put the temporary file in the permanent location
if (move_uploaded_file($_FILES['uploadfile']['tmp_name'], $file)) {
echo "Success";
// set the date and time when the file finished transfering for the email
//$now = date('l\, F jS\, Y \a\t H:i:s');
// send the email
//$to = "me@me.com";
//$subject = "File Uploaded";
//$file_type = $_POST['upload_type'];
//$message = "The file $file_name was uploaded to article $id_is on $now. $file_is type is $type form is set $it_is";
//$from = "From:mw@me.com";
//mail($to, $subject, $message, $from);
//if there was a problem putting the temporary file in the permanent location
}
else
{
echo "error ".$_FILES['uploadfile']['error']." --- ".$_FILES['uploadfile']['tmp_name']." %%% ".$file."($size)";
}
?>
The file input name is "uploadfile", I think it might be the domain structuring but I'm not sure. The domain is like this http://www.mydomain.com/test/php/jquery/upload-file.php?id=1234. I'm trying to put the file in http://www.mydomain.com/files/ftp_upload/1234/
This is what I get for an output
./../../../files/ftp_upload/1234/
./../../../files/ftp_upload/1234/
error --- %%% ./../../../files/ftp_upload/1234/()