RSS Forums RSS
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 843 | Replies: 6 | Thread Tools  Display Modes
Reply
Join Date: Jan 2008
Posts: 3
Reputation: kenchiro is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
kenchiro kenchiro is offline Offline
Newbie Poster

Please help file name and folder name it doesn't array A-Z,0-9

  #1  
Jan 21st, 2008
Please help me file name and folder name when upload by by browser Folder and file name it does not array .. A B C-Z or 1-9 ..please help me to fix this problem... Really thanks
the cause is when i moved to new hosting it happen like this problem
Pleaseeeee... fix this problem to help.. i don;t know how to fix it ( coz this is a open source and i don't know about php that much )

<?

require_once ("../include/errorhandling.php");
require_once ("../include/config.php");

$GLOBALS["rootdp"] = '../';
include ("../include/access.php");



include ("../include/functions.php");
include ("../include/settings.php");
include ("../".$GLOBALS["language_home"].$GLOBALS["gsLanguage"]."/lang_admin.php");
include ("../".$GLOBALS["language_home"].$GLOBALS["gsLanguage"]."/lang_images.php");

if (!isset($HTTP_GET_VARS["subdir"]))
{
$subdir = '';
}
else
{
$subdir = $HTTP_GET_VARS["subdir"];
}

$ImageFileTypes[] = "gif";
$ImageFileTypes[] = "jpg";
$ImageFileTypes[] = "png";

force_page_refresh();
frmImages();


function frmImages()
{
global $ImageFileTypes, $subdir;
global $HTTP_GET_VARS;
?>
<html>
<head>
<LINK HREF="<? echo $GLOBALS["rootdp"].$GLOBALS["style_home"]; ?>vs.css" REL=STYLESHEET TYPE="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=windows-874">
</head>
<body leftmargin=0 topmargin=0 marginwidth="0" marginheight="0" bgcolor="#000000">
<table border="0" width="100%" cellspacing="3" cellpadding="3">
<tr bgcolor="#505050">
<td colspan="4" align="center">
<b><? echo $GLOBALS["tFormTitle"]; ?></b>
</td>
</tr><?

// Generate image tags for the different images that appear on the page
$GLOBALS["iFirst"] = lsimagehtmltag($GLOBALS["icon_home"],'first1.gif',$GLOBALS["gsLanguage"],$GLOBALS["tFirstPage"],0);
$GLOBALS["iPrev"] = lsimagehtmltag($GLOBALS["icon_home"],'last1.gif',$GLOBALS["gsLanguage"],$GLOBALS["tPrevPage"],0);
$GLOBALS["iNext"] = lsimagehtmltag($GLOBALS["icon_home"],'next1.gif',$GLOBALS["gsLanguage"],$GLOBALS["tNextPage"],0);
$GLOBALS["iLast"] = lsimagehtmltag($GLOBALS["icon_home"],'end1.gif',$GLOBALS["gsLanguage"],$GLOBALS["tLastPage"],0);
$GLOBALS["iAddNew"] = lsimagehtmltag($GLOBALS["icon_home"],'addnew.gif',$GLOBALS["gsLanguage"],$GLOBALS["tAddNewMenu"],0);
$iDelete = lsimagehtmltag($GLOBALS["icon_home"],'del_e-wrs.gif',$GLOBALS["gsLanguage"],$GLOBALS["tDeleteMenu"],0);
$iOpenFolder = lsimagehtmltag($GLOBALS["icon_home"],'floderphotos2.gif','',0,'');
$iBlank = lsimagehtmltag($GLOBALS["icon_home"],'blank.gif','',0,'');

if($HTTP_GET_VARS["page"] != "")
{
$nCurrentPage = $HTTP_GET_VARS["page"];
}
else
{
$nCurrentPage = 0;
}

$lRecCount = lCountImages();
$nPages = intval(($lRecCount - 0.5) / $GLOBALS["RECORDS_PER_PAGE"]) + 1;
$lStartRec = $nCurrentPage * $GLOBALS["RECORDS_PER_PAGE"];

frmImagesHdFt(4,$nCurrentPage,$nPages);
?>
$array = $GLOBALS[$tImageName];
<tr bgcolor="#99CC00">
<td colspan="4" align="left"><? echo $GLOBALS["image_home"].$subdir ?></td>
</tr>
<tr bgcolor="#FFCC00">
<td width="30%"><b><? echo $GLOBALS["tDel"]; ?></b></td>
<td width="40%"><b><? echo $GLOBALS["tImageName"]; ?></b></td>
<td width="15%">&nbsp;</td>
<td width="15%">&nbsp;</td>
</tr><?

$nImageNr = 0;
$nImageShowed = 0;

$savedir = getcwd();
chdir($GLOBALS["rootdp"].$GLOBALS["image_home"].$subdir);

if ($handle = @opendir('.'))
{
while ($file = readdir($handle))
{
$filename = $file;
if (is_file($filename))
{
$fileparts = pathinfo($filename);
$file_ext = $fileparts["extension"];
if (in_array($file_ext,$ImageFileTypes))
{
if ($nImageNr >= $lStartRec && $nImageShowed < $GLOBALS["RECORDS_PER_PAGE"])
{
?><tr bgcolor="#99CCFF">
<td align="center" valign="middle">
<? echo $iBlank; ?>
<a href="javascriptelImage('subdir=<? echo $subdir; ?>&Image=<? echo $file; ?>&page=<? echo $HTTP_GET_VARS["page"]; ?>')"><? echo $iDelete; ?></a>
</td>
<td valign="top"><a href="javascripthowImage('<? echo $GLOBALS["rootdp"].$GLOBALS["image_home"].$subdir.$file; ?>')"><? echo $file; ?></a></td>
<td align="right" valign="top"><? echo display_size(filesize($file)); ?></td><?
$size = GetImageSize($filename);
$imagesize1 = $size["0"];
$imagesize2 = $size["1"]; ?>
<td align="center" valign="top"><? echo $imagesize1.' x '.$imagesize2; ?></td>
</tr><?
$nImageShowed++;
}
$nImageNr++;
}
}
elseif (is_dir($filename))
{
if ((($subdir != '') && ($filename != '.')) || (($subdir == '') && ($filename != '.') && ($filename != '..')))
{
if ($nImageNr >= $lStartRec && $nImageShowed < $GLOBALS["RECORDS_PER_PAGE"])
{
if ($filename != '..')
{
$newsubdir = $subdir.$filename.'/';
}
else
{
$dirbreakdown = explode('/',$subdir);
array_pop($dirbreakdown); array_pop($dirbreakdown);
$newsubdir = implode('/',$dirbreakdown).'/';
if ($newsubdir == '/')
{
$newsubdir = '';
}
}

?><tr bgcolor="#6699FF">
<td align="center" valign="middle"><?

if ($filename != '..')
{
?><a href="m_images.php?subdir=<? echo $newsubdir; ?>"><? echo $iOpenFolder; ?></a>
<a href="javascriptelDir('subdir=<? echo $subdir; ?>&folder=<? echo $file; ?>&page=<? echo $HTTP_GET_VARS["page"]; ?>')"><? echo $iDelete; ?></a><?
}

?></td>
<td valign="top"><a href="m_images.php?subdir=<? echo $newsubdir; ?>"><? echo $filename; ?></a></td>
<td align="center" valign="middle">&nbsp;</td>
<td align="center" valign="middle">&nbsp;</td>
</tr><?
$nImageShowed++;
}
$nImageNr++;
}
}
}
closedir($handle);
}
chdir($savedir);

frmImagesHdFt(4,$nCurrentPage,$nPages);
?>
</table>
</body>
</html><?
} // function frmImages()


function lCountImages()
{
global $ImageFileTypes, $subdir;

$nImageCount = 0;
$savedir = getcwd();
chdir($GLOBALS["rootdp"].$GLOBALS["image_home"].$subdir);

if ($handle = @opendir('.'))
{
while ($file = readdir($handle))
{
$filename = $file;
if (is_file($filename))
{
$fileparts = pathinfo($filename);
$file_ext = $fileparts["extension"];
if (in_array($file_ext,$ImageFileTypes))
{
$nImageCount++;
}
}
elseif
(is_dir($filename))
{
if (($subdir != '') || ($filename != '..'))
{
$nImageCount++;
}
}
}

closedir($handle);
}
chdir($savedir);

return $nImageCount;
} // function lCountImages()

?>

<script language="Javascript">

function DelImage(sParams)
{
if(window.confirm('<? echo $GLOBALS["tConfirmDeletion"]; ?>'))
{
location.href='m_imagedel.php?' + sParams;
}
}

function DelDir(sParams)
{
if(window.confirm('<? echo $GLOBALS["tConfirmDeletion"]; ?>'))
{
location.href='removedir.php?' + sParams;
}
}

function ShowImage(sImageName)
{
window.open(sImageName, "Image", "width=500,height=400,status=no,resizable=yes,scrollbars=yes");
}

function UploadImage()
{
window.open("uploadimage.php?subdir=<? echo $subdir; ?>", "UploadImage", "width=600,height=310,status=no,resizable=no,scrollbars=no");
}

</script>
<?


function frmImagesHdFt($colspan,$nCurrentPage,$nPages)
{
global $subdir;
?>
<tr bgcolor="#FFFFFF">
<td colspan="<? echo $colspan; ?>" align="left">
<table height="100%" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td align="left" valign="bottom">
<a href="javascript:UploadImage();"><? echo $GLOBALS["iAddNew"]; ?></a>
</td>

<td align="right" valign="bottom"><font face="Arial Black" size="1" color="#CC0000">
<a href="m_images.php?subdir=<? echo $subdir; ?>&page=0">
<? echo $GLOBALS["iFirst"]; ?>
</a>
<?
if ($nCurrentPage != 0)
{
?>
<a href="m_images.php?subdir=<? echo $subdir; ?>&page=<? echo $nCurrentPage - 1; ?>">
<? echo $GLOBALS["iPrev"]; ?>
</a>
<?
}
else
{
echo $GLOBALS["iPrev"];
}
$nCPage = $nCurrentPage + 1;

echo '&nbsp;&nbsp;'.$GLOBALS["tPage"].' '.$nCPage.' '.$GLOBALS["tOf"].' '.$nPages.'&nbsp;&nbsp;';
if ($nCurrentPage + 1 != $nPages)
{
?>
<a href="m_images.php?subdir=<? echo $subdir; ?>&page=<? echo $nCurrentPage + 1; ?>">
<? echo $GLOBALS["iNext"]; ?>
</a>
<?
}
else
{
echo $GLOBALS["iNext"];
}

?>
<a href="m_images.php?subdir=<? echo $subdir; ?>&page=<? echo $nPages - 1; ?>">
<? echo $GLOBALS["iLast"]; ?>
</a> </td>
</tr>
</table>
</td>
</tr><?
} // function frmImagesHdFt()


function display_size($file_size)
{
if ($file_size >= 1073741824)
{
$file_size = round($file_size / 1073741824 * 100) / 100 ."g";
}
elseif($file_size >= 1048576)
{
$file_size = round($file_size / 1048576 * 100) / 100 ."m";
}
elseif($file_size >= 1024)
{
$file_size = round($file_size / 1024 * 100) / 100 ."k";
}
else
{
$file_size = $file_size." bytes";
}

return $file_size;
} // function display_size()

?>
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 9
Solved Threads: 240
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: Please help file name and folder name it doesn't array A-Z,0-9

  #2  
Jan 21st, 2008
Explain your problem in detail. What do you mean by filename and foldername it doesnt array A-Z,0-9 ? Also, when posting your code, put it in [code =php][/code ] tags.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

*PM asking for help will be ignored*
Reply With Quote  
Join Date: Jan 2008
Posts: 3
Reputation: kenchiro is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
kenchiro kenchiro is offline Offline
Newbie Poster

Re: Please help file name and folder name it doesn't array A-Z,0-9

  #3  
Jan 21st, 2008
I mean... When i upload photo ( .jpg .gif .png )
such as a.jpg b.jpg c.jpg e.jpg c.jpg
it should arrange photo file
a.jpg
b.jpg
c.jpg
d.jpg
e.jpg
c.jpg
Step by step of A - Z
when upload by browser
but it arrange like this
e.jpg
a.jpg
c.jpg
d.jpg
b.jpg
not arrange a b c d e f
i want it arrange a b c d e f of file name

Sorry if my english is not good
Thank you very much
Best regards,
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 9
Solved Threads: 240
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: Please help file name and folder name it doesn't array A-Z,0-9

  #4  
Jan 21st, 2008
When you upload an image to the server, you can connect to your server through ftp, right click and arrange the files by name. What difference will it make anyway ?
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

*PM asking for help will be ignored*
Reply With Quote  
Join Date: Jan 2008
Posts: 3
Reputation: kenchiro is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
kenchiro kenchiro is offline Offline
Newbie Poster

Re: Please help file name and folder name it doesn't array A-Z,0-9

  #5  
Jan 21st, 2008
I know that way about ftp.. but i would like anyone help me to fix this problem.. because i do not want someone upload by ftp...
Really thanks nv33n
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 9
Solved Threads: 240
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: Please help file name and folder name it doesn't array A-Z,0-9

  #6  
Jan 21st, 2008
I really have no clue how you can 'sort by name' when you upload an image using html file upload. What you can do is, when fetching the images from ftp, you can put all the names in an array and use sort function to sort the array.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

*PM asking for help will be ignored*
Reply With Quote  
Join Date: Sep 2007
Location: Budapest
Posts: 252
Reputation: fatihpiristine has a little shameless behaviour in the past 
Rep Power: 0
Solved Threads: 14
fatihpiristine's Avatar
fatihpiristine fatihpiristine is offline Offline
Posting Whiz in Training

Re: Please help file name and folder name it doesn't array A-Z,0-9

  #7  
Jan 21st, 2008
i have posted that script ages ago..

here u can view them like 6*4 or how you like
http://www.daniweb.com/forums/thread93324.html

here is the file upload code. u have to do some modifications on it.

  1. <?php
  2. //--------------------------------------------------------------------------------
  3. $path = "D:\websites\mysite.com\Uploads\\";
  4. $web = "../uploads/";
  5. $nopic = "../images/nopic.jpg";
  6. $ad = "add_item";
  7. $no = "1";
  8. $page = $ad.$no;
  9. //--------------------------------------------------------------------------------
  10. $isim = $_REQUEST['NewsID'];
  11. $tip = $_FILES[img1][type];
  12. $size = $_FILES[img1][size];
  13. //--------------------------------------------------------------------------------
  14. $Edit = $_COOKIE['Edit'.$no];
  15. if($Edit != "")
  16. {
  17. $GetID = "select * from news where NewsID='" . $isim . "'";
  18. $FindID=mysql_query($GetID);
  19. while($WriteID = mysql_fetch_array($FindID))
  20. {
  21. if($WriteID['Resim'.$no] != "")
  22. {
  23. setcookie('Edit'.$no,'');
  24. $dosya = $WriteID['Resim'.$no];
  25. }
  26. else
  27. {
  28. setcookie('Edit'.$no,'');
  29. $dosya = $nopic;
  30. }
  31. }
  32. }
  33. //--------------------------------------------------------------------------------
  34. elseif($size >= 150000)
  35. {
  36. $dosya = $nopic;
  37. //Temizle
  38. $sil1 = $isim."_".$no.".jpg";
  39. $sil2 = $isim."_".$no.".png";
  40. $sil3 = $isim."_".$no.".gif";
  41. @unlink($path.$sil1);
  42. @unlink($path.$sil2);
  43. @unlink($path.$sil3);
  44. $uyari = "<small>Max 150Kb</small>";
  45. }
  46. //--------------------------------------------------------------------------------
  47. elseif($tip == "image/jpeg" || $tip == "image/pjpeg")
  48. {
  49. $dosya = $isim."_".$no.".jpg";
  50. //Temizle
  51. $sil1 = $isim."_".$no.".jpg";
  52. $sil2 = $isim."_".$no.".png";
  53. $sil3 = $isim."_".$no.".gif";
  54. @unlink($path.$sil1);
  55. @unlink($path.$sil2);
  56. @unlink($path.$sil3);
  57. // Veritabanina Yaz
  58. $query = "update news set Resim". $no ." ='" . $dosya . "' where NewsID=". $isim ."";
  59. mysql_query($query) or die(mysql_error());
  60. //Kopyala
  61. @copy($_FILES[img1][tmp_name],$path.$dosya);
  62.  
  63. }
  64. //--------------------------------------------------------------------------------
  65. elseif($tip == "image/png" || $tip == "image/x-png")
  66. {
  67. $dosya = $isim."_".$no.".png";
  68. //Temizle
  69. $sil1 = $isim."_".$no.".jpg";
  70. $sil2 = $isim."_".$no.".png";
  71. $sil3 = $isim."_".$no.".gif";
  72. @unlink($path.$sil1);
  73. @unlink($path.$sil2);
  74. @unlink($path.$sil3);
  75. // Veritabanina Yaz
  76. $query = "update news set Resim". $no ." ='" . $dosya . "' where NewsID=". $isim ."";
  77. mysql_query($query) or die(mysql_error());
  78. //Kopyala
  79. @copy($_FILES[img1][tmp_name],$path.$dosya);
  80. }
  81. //--------------------------------------------------------------------------------
  82. elseif($tip == "image/gif")
  83. {
  84. $dosya = $isim."_".$no.".gif";
  85. //Temizle
  86. $sil1 = $isim."_".$no.".jpg";
  87. $sil2 = $isim."_".$no.".png";
  88. $sil3 = $isim."_".$no.".gif";
  89. @unlink($path.$sil1);
  90. @unlink($path.$sil2);
  91. @unlink($path.$sil3);
  92. // Veritabanina Yaz
  93. $query = "update news set Resim". $no ." ='" . $dosya . "' where NewsID=". $isim ."";
  94. mysql_query($query) or die(mysql_error());
  95. //Kopyala
  96. @copy($_FILES[img1][tmp_name],$path.$dosya);
  97. }
  98. //--------------------------------------------------------------------------------
  99. elseif($tip == "" )
  100. {
  101. $dosya = $nopic;
  102. }
  103. //--------------------------------------------------------------------------------
  104. elseif($tip != "image/jpeg" || $tip != "image/pjpeg" || $tip != "image/png" || $tip != "image/x-png" || $tip != "image/gif" || $tip != "")
  105. {
  106. $dosya = $nopic;
  107. $uyari = "<small>Geçersiz format</small>";
  108. }
  109. //--------------------------------------------------------------------------------
  110. ?>
  111. <?php
  112. $Delete = $_GET['Delete'];
  113. $FileName = $_GET['FileName'];
  114. if($Delete == "OK")
  115. {
  116. // Veritabanindan Sil
  117. $query = "update news set Resim". $no ." ='' where NewsID=". $isim ."";
  118. mysql_query($query) or die(mysql_error());
  119. @unlink($path.$FileName);
  120. $dosya = $nopic;
  121. }
  122. ?>
  123. <html>
  124. <script language=JavaScript src='../js/controls.js'></script>
  125. <script language="javascript">
  126. // resim yuklemede loading resmi gosterme
  127. document.write('<div id="loading"><table align="center" border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td align="center" height="100%"><br><img src="../images/loading.gif" alt="" align="middle"><br>Lütfen bekleyin...</td></tr></table></div>');
  128.  
  129. window.onload=function()
  130. {
  131. document.getElementById("loading").style.display="none";
  132. }
  133. </script>
  134. <body topmargin="0" leftmargin="0">
  135. <form method="post" action="<?php print $page ?>.php" enctype="multipart/form-data">
  136. <table width="90" border="0" cellspacing="0" cellpadding="0">
  137. <tr>
  138. <td align="center">
  139. <img name="img1" src="<?php if($dosya == $nopic) { print $dosya; } else { print $web.$dosya; } ?>" width="85" height="85">
  140. <?php if($dosya != $nopic) { $_POST[$dosya]; print "<br><a onclick='return resim_sil()' href=$page.php?Delete=OK&FileName=$dosya>Resmi Sil</a>&nbsp;"; } ?>
  141. <?php if($dosya == $nopic) { print $uyari;} ?>&nbsp;<br>
  142. </td>
  143. </tr>
  144. <tr>
  145. <td>
  146. <input type="file" name="img1" accept="image/gif,image/jpeg,image/png" onChange="LimitAttach(this.form, this.form.img1.value)" size="1" style="width:80; border:none;">
  147. </td>
  148. </tr>
  149. </table>
  150. </form>
  151. </body>
  152. </html>
  153.  

btw file names depends on NewID, which means there should be an ID posted from somewhere.
i hope you gonna understand it
Last edited by fatihpiristine : Jan 21st, 2008 at 11:25 pm.
Do a favour, leave me alone
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.



Similar Threads
Other Threads in the PHP Forum
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 12:04 am.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC