Jump to content

[SOLVED] is_uploaded_file


seventheyejosh

Recommended Posts

hello! i seem to be having a problem with my dynamic file uploading. basically, the user can only upload up to 100 photos per album, so i have this code that makes the input boxes:

 

sql::connect();

$albumid=$_REQUEST['id'];

 

$cres=sql::query("SELECT COUNT(*) FROM photos WHERE `album` = '$albumid'");

$crow=sql::getrow($cres);

$count=$crow[0];

 

$new=(100-$count);

 

if ($new>10){$limit=10;}else {$limit=$new;}

echo "<table width=100% class=tablecell align=center height=100% cellpadding=2 cellspacing=0 border=0>\n";

echo "<tr><td colspan=2 width=100% align=center><hr></hr></td></tr>\n";

for ($i=1;$i<($limit+1);$i++){

echo "<tr>\n";

echo "<td align=right width=25%>\n";

echo "Photo $i: \n";

echo "</td>\n";

echo "<td align=left width=75% colspan=3>\n";

echo "<input type=file name=\"photo$i\">\n";

echo "</td>\n";

echo "</tr>\n";

echo "<tr>\n";

echo "<td align=right width=25%>\n";

echo "Caption $i: \n";

echo "</td>\n";

echo "<td align=left width=75% colspan=3>\n";

echo "<input type=text name=\"caption$i\">\n";

echo "</td>\n";

echo "</tr>\n";

echo "<tr><td colspan=2 width=100% align=center><hr></hr></td></tr>\n";

} // end for

echo "<input type=hidden name=p_count value=\"$i\">\n";

echo "</table>\n";

 

 

 

and this code that retrieves it:

 

sql::connect();

$album=$_REQUEST['new_album'];

$date=$_REQUEST['new_date'];

$p_count=$_REQUEST['p_count'];

global $php_dir;

 

for ($i=1;$i<$p_count;$i++){

 

eval("\$caption=\$_REQUEST['caption$i'];");

 

eval("if(@is_uploaded_file(\$_FILES['photo$id']['tmp_name']));");

{

eval("\$file=\$_FILES['photo$id']['name'];");

$file=strtolower($file);

$info=split('[.]',$file);

$ext=$info[count($info)-1];

$file=time().$i.'.'.$ext;

//copy($_FILES["['photo$id'], "$php_dir/events/banner/".$file);

 

//sql::query("INSERT INTO photos (`album`,`date`,`caption`,`path`,`views`) VALUES

// ('$album','$date','$caption','$path','0')");

echo "file - $file caption - $caption album - $album date - $date";

echo "<br />\n";

} // end if

 

} // end for

 

exit();

 

note that my actual save is commented out and i'm echoing the filename, then exiting to see wats up. for some reason even if there is no file uploaded, its running the echo/save all 10 times. this is what is displayed on the screen:

 

file - 12368748791. caption - pigy album - 2 date -

file - 12368748792. caption - mario album - 2 date -

file - 12368748793. caption - fake album - 2 date -

file - 12368748794. caption - album - 2 date -

file - 12368748795. caption - album - 2 date -

file - 12368748796. caption - album - 2 date -

file - 12368748797. caption - album - 2 date -

file - 12368748798. caption - album - 2 date -

file - 12368748799. caption - album - 2 date -

file - 123687487910. caption - album - 2 date -

 

note that only the first 3 have info, cause there are only 3 uploaded! is there something im missing about my if is uploaded? something that would run through it anyway?

 

thanks in advance!

Link to comment
https://forums.phpfreaks.com/topic/149119-solved-is_uploaded_file/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.