Simple Machines Community Forum

SMF Support => SMF 2.0.x Support => Aiheen aloitti: subzero_mb - helmikuu 23, 2009, 11:30:36 AP

Otsikko: SSI.php problem with upload
Kirjoitti: subzero_mb - helmikuu 23, 2009, 11:30:36 AP
Hi everybody!
I have a website with smf 2.0 integrated with the whole site, so for that reason I have in the header of every document of the web the SSI.php file loaded. I am programing for a section of the web (no for the forum) one file uploader, but I am having a problem. The script works perfectly, it is very easy and you can see here.

<?php 
if ($imagen)
move_uploaded_file($HTTP_POST_FILES[file]['tmp_name'], "file");
?>


<form name="form" action="upload.php" method="post" enctype="multipart/form-data">
File: <input name="file" type="file" id="file" size="13" />
        <input type="submit" name="submit" value="Send" />
</form>


The problem appears when I include the SSI.php file, before of that you choose the file, push send and the file was uploaded, but the same script with the SSI.php loaded doesn´t work  >:(
<?php 
include ("forum/ssi.php");
if (
$imagen)
move_uploaded_file($HTTP_POST_FILES[file]['tmp_name'], "file");
?>


<form name="form" action="upload.php" method="post" enctype="multipart/form-data">
File: <input name="file" type="file" id="file" size="13" />
        <input type="submit" name="submit" value="Send" />
</form>

The script doesn´t show any error, but when you look in the server there isn´t any file.
Does anybody know why the SSI.php file doesn´t allow the upload?? I cannot find any solution. Thank you very much
Otsikko: Re: SSI.php problem with upload
Kirjoitti: Xylar2 - helmikuu 23, 2009, 11:55:17 AP
Try This ;):
<?php 
include ("forum/ssi.php");
if (
$imagen)
move_uploaded_file($HTTP_POST_FILES[file]['tmp_name'], "file");

<
form name="form" action="upload.php" method="post" enctype="multipart/form-data">
File: <input name="file" type="file" id="file" size="13" />
        <
input type="submit" name="submit" value="Send" />
</
form>
?>

Otsikko: Re: SSI.php problem with upload
Kirjoitti: subzero_mb - helmikuu 23, 2009, 01:38:54 IP
That was a joke or what?? :-\ You just have move the "?>" to the end of the script and you left the html without a echo or a print  :o
Otsikko: Re: SSI.php problem with upload
Kirjoitti: subzero_mb - helmikuu 24, 2009, 02:13:02 IP
Nobody knows??
Otsikko: Re: SSI.php problem with upload
Kirjoitti: greyknight17 - maaliskuu 15, 2009, 01:17:05 IP
subzero_mb, do you still  need help with this problem?

Not sure if this will help, but give the following a try:

<?php 
include ("forum/ssi.php");
if (
$imagen)
   
move_uploaded_file($HTTP_POST_FILES[file]['tmp_name'], "file");

echo 
'
        <form name="form" action="upload.php" method="post" enctype="multipart/form-data">
File: <input name="file" type="file" id="file" size="13" />
        <input type="submit" name="submit" value="Send" />
</form>'
;
?>
Otsikko: Re: SSI.php problem with upload
Kirjoitti: SlammedDime - maaliskuu 15, 2009, 01:40:30 IP
Try $_FILES instead of $HTTP_POST_FILES.
Otsikko: Re: SSI.php problem with upload
Kirjoitti: subzero_mb - maaliskuu 15, 2009, 06:58:56 IP
Thank you soooooo much SlammedDime!! You did it! That was the problem, if I use _FILES instead of HTTP_POST_FILES everything is ok. I don´t know why now works, could you explaind me the reason? Just for knowledge. SSI.php file locks Post variables? Thank you!
Otsikko: Re: SSI.php problem with upload
Kirjoitti: SlammedDime - maaliskuu 15, 2009, 07:09:20 IP
HTTP_POST_FILES is deprecated as of PHP 4.1.0, and is not a superglobal.  It might have worked had you done global $HTTP_POST_FILES AFTER including SSI.php, but it would still be inproper, due to deprecation.  $_FILES is the correct way these days to retrieve the information.

http://us.php.net/manual/en/reserved.variables.files.php