Forum Moderators: coopster
I'm using mamp to run my mac as a test server for the following code - which is part of a wordpress theme. I'm using version 2.6.2.
@$upload_Name = $_FILES['upload']['name'];
@$upload_Size = $_FILES['upload']['size'];
@$upload_Temp = $_FILES['upload']['tmp_name'];
@$upload_Mime_Type = $_FILES['upload']['type'];
if( $upload_Size == 0)
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid upload</font></p>");
}
if( $upload_Size >5000000)
{
//delete file
unlink($upload_Temp);
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid upload</font></p>");
}
if( $upload_Mime_Type != "application/pdf")
{
unlink($upload_Temp);
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid upload</font></p>");
}
$uploadFile = "uploads/".$upload_Name ;
if (!is_dir(dirname($uploadFile)))
{
@RecursiveMkdir(dirname($uploadFile));
}
else
{
@chmod(dirname($uploadFile), 0777);
}
@move_uploaded_file( $upload_Temp , $uploadFile);
chmod($uploadFile, 0644);
// Change This....
$upload_URL = "http://localhost:8888/wordpress/uploads/".$upload_Name ;
?>
I've done everything I can think of to validate the code. I've checked the form is actually passing the variables. I've checked the validation procedure.
Now I'm thinking (or rather hoping) that its something to do with my testing enviroment - but I don't understand every single line of the code, so its hard to know.
Could you please look it over for me and see if the code is failing somewhere.
Also, can a mamp server/wordpress setup handle this type of operation?
What actually happens?
does the file not get moved?
does it die silently?
does nothing happen after you submit the form?
we can't really test this code, I don't even have wordpress, but with a little more data we might be able to give some ideas
As of now, all the file upload values are successfully passed to the proccessor. All the validation checks appear to be passed successfully - the thank you page appears as expected, but the pdf does not upload either into the temporary location or the pernament one. My best guess is that the script is dying somewhere after the final die statement. Actually I'll test that and post the result.