Hey all, Im using an awsome package to upload multiples files once.
[URL=”http://www.element-it.com/MultiPowUpload.aspx”]http://www.element-it.com/MultiPowUpload.aspx
I Need to rename every file to 1.jpg, 2.jpg, 3.jpg etc sequentially.
[CODE]<?php
$file = str_replace(basename($_SERVER[‘PHP_SELF’]),”,($_SERVER[‘PHP_SELF’]));
$uploaddir = $_SERVER[‘DOCUMENT_ROOT’] . $file . “Images/”;
$uploadfile = $uploaddir . basename($_FILES[‘Filedata’][‘name’]);
move_uploaded_file ($_FILES[‘Filedata’][‘tmp_name’], $uploadfile);
This Uploads all the files to an images folder with the original names.
And when i add this to the above
[CODE]
$count = count($_FILES[‘Filedata’]);
for ($i=1; $i <= $count; $i++) {
rename($uploadfile, $uploaddir . $i. “.jpg”);
};
?>
It renames the files the way i need them but just the wrong amount of times.
So i guesss my question is What would i ‘count’ to get the right reference number for the loop? eg How many files im uploading.
Iv been on this problem for the past eight hours, im relativley new. Any help would in my books win you a nomination for Nobile Peace prize ?
Thanks in advance
<i>
</i>$uploadfile = $uploaddir . basename($_FILES['Filedata']['name']);
<i>
</i>$uploadfile = $uploaddir . basename($_FILES['Filedata'][$i]);
[code=php]$count = count(array_keys($_FILES['Filedata']['error'], 0));[/code]
That should get you the number of successful uploads.[CODE]
<?php
$file = str_replace(basename($_SERVER['PHP_SELF']),'',($_SERVER['PHP_SELF']));
$uploaddir = $_SERVER['DOCUMENT_ROOT'] . $file . "Images/";
$uploadfile = $uploaddir . basename($_FILES['Filedata']['name']);
move_uploaded_file ($_FILES['Filedata']['tmp_name'], $uploadfile);
$count = count(array_keys($_FILES['Filedata']['error'],0));
for ($i=0; $i <= $count; $i++) {
rename($uploadfile, $uploaddir . $i. ".jpg");
};
?> [/CODE]
[CODE]
<?php
$file = str_replace(basename($_SERVER['PHP_SELF']),'',($_SERVER['PHP_SELF']));
$uploaddir = $_SERVER['DOCUMENT_ROOT'] . $file . "Images/";
$uploadfile = $uploaddir . basename($_FILES['Filedata']['name']);
move_uploaded_file ($_FILES['Filedata']['tmp_name'], $uploadfile);
?>
[/CODE]
[CODE]<html>
<head>
<title>Adding / Deleting into database</title>
<?php include 'database.php';?>
</head>
<script language="JavaScript">
function mysubmit(type)
{
if(type=='flash')
{
var Flash;
if(document.embeds && document.embeds.length>=1)
Flash = document.getElementById("EmbedFlashFilesUpload");
else
Flash = document.getElementById("FlashFilesUpload");
Flash.SetVariable("uploadUrl", "winupload.php");
Flash.SetVariable("SubmitFlash", "");
var FormObj = document.getElementById("myform");
FormObj.action = "winupload.php";
return true;
}
else
{
var FormObj = document.getElementById("myform");
FormObj.action = "winupload.php";
return true;
}
}
</script>
<body>
<div id= "input">
<br><b>Insert text here</b>
<form action="insert.php" method="post">
<input type="text" name="value" />
<input type="submit" name="submit" value="Insert">
</form>
</div>
<div id="output">
<br><br>
<form action="delete.php" method="post">
<select name="gallery" title="Galleries">
<?php
$result = mysql_query("SELECT * FROM testtable");
while ($rows = mysql_fetch_array($result)) {
$id = $rows['id'];
$names = $rows['testField'];
echo "<option id="$id">$names</option><br>";
};
?>
</select>
<input type="submit" name="delete" value="Delete">
</form>
<form action="upload.php" method="post" enctype="multipart/form-data">
<input type="file" name="file" size="30">
<input type="submit" value="Submit">
</form>
<form method="post" action="output.php">
<input type="submit" name="upload" value="Write XML">
</form>
<OBJECT id="FlashFilesUpload" codeBase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"
width="450" height="300" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" VIEWASTEXT>
<!-- Replace symbols " with the " at all parameters values and
symbols "&" with the "%26" at URL values or & at other values! -->
<PARAM NAME="FlashVars" VALUE="uploadUrl=&uploadButtonVisible=No">
<PARAM NAME="BGColor" VALUE="#F8F6E6">
<PARAM NAME="Movie" VALUE="ElementITMultiPowUpload1.6.swf">
<PARAM NAME="Src" VALUE="ElementITMultiPowUpload1.6.swf">
<PARAM NAME="WMode" VALUE="Window">
<PARAM NAME="Play" VALUE="-1">
<PARAM NAME="Loop" VALUE="-1">
<PARAM NAME="Quality" VALUE="High">
<PARAM NAME="SAlign" VALUE="">
<PARAM NAME="Menu" VALUE="-1">
<PARAM NAME="Base" VALUE="">
<PARAM NAME="AllowScriptAccess" VALUE="always">
<PARAM NAME="Scale" VALUE="ShowAll">
<PARAM NAME="DeviceFont" VALUE="0">
<PARAM NAME="EmbedMovie" VALUE="0">
<PARAM NAME="SWRemote" VALUE="">
<PARAM NAME="MovieData" VALUE="">
<PARAM NAME="SeamlessTabbing" VALUE="1">
<PARAM NAME="Profile" VALUE="0">
<PARAM NAME="ProfileAddress" VALUE="">
<PARAM NAME="ProfilePort" VALUE="0">
<!-- Embed for Netscape,Mozilla/FireFox browsers support. Flashvars parameters are the same.-->
<!-- Replace symbols " with the " at all parameters values and
symbols "&" with the "%26" at URL values or & at other values! -->
<embed bgcolor="#F8F6E6" id="EmbedFlashFilesUpload" src="ElementITMultiPowUpload1.6.swf" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="400" height="350" flashvars="uploadUrl=&uploadButtonVisible=No">
</embed>
</OBJECT>
<br>
<input onClick="mysubmit('flash');" id="myform" type="button" value="Send Files" name="myform" />
</div>
</body>
</html>
[/CODE]
If you wanna check out the package it only takes ten mins or so to setup ?[/QUOTE]The package has nothing to do with PHP... and the processing script you are using is not for multiple uploads. You need concordance between your clientside and serverside scripts so they can work in harmony.
[CODE]<html>
<head>
<title>Adding / Deleting into database</title>
<?php include 'database.php';?>
</head>
<script language="JavaScript">
function mysubmit(type)
{
if(type=='flash')
{
var Flash;
if(document.embeds && document.embeds.length>=1)
Flash = document.getElementById("EmbedFlashFilesUpload");
else
Flash = document.getElementById("FlashFilesUpload");
Flash.SetVariable("uploadUrl", "winupload.php");
Flash.SetVariable("SubmitFlash", "");
var FormObj = document.getElementById("myform");
FormObj.action = "winupload.php";
return true;
}
else
{
var FormObj = document.getElementById("myform");
FormObj.action = "winupload.php";
return true;
}
}
</script>
<body>
<div id= "input">
<br><b>Insert text here</b>
<form action="insert.php" method="post">
<input type="text" name="value" />
<input type="submit" name="submit" value="Insert">
</form>
</div>
<div id="output">
<br><br>
<form action="delete.php" method="post">
<select name="gallery" title="Galleries">
<?php
$result = mysql_query("SELECT * FROM testtable");
while ($rows = mysql_fetch_array($result)) {
$id = $rows['id'];
$names = $rows['testField'];
echo "<option id="$id">$names</option><br>";
};
?>
</select>
<input type="submit" name="delete" value="Delete">
</form>
<form action="upload.php" method="post" enctype="multipart/form-data">
<input type="file" name="file" size="30">
<input type="submit" value="Submit">
</form>
<form method="post" action="output.php">
<input type="submit" name="upload" value="Write XML">
</form>
<OBJECT id="FlashFilesUpload" codeBase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"
width="450" height="300" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" VIEWASTEXT>
<!-- Replace symbols " with the " at all parameters values and
symbols "&" with the "%26" at URL values or & at other values! -->
<PARAM NAME="FlashVars" VALUE="uploadUrl=&uploadButtonVisible=No">
<PARAM NAME="BGColor" VALUE="#F8F6E6">
<PARAM NAME="Movie" VALUE="ElementITMultiPowUpload1.6.swf">
<PARAM NAME="Src" VALUE="ElementITMultiPowUpload1.6.swf">
<PARAM NAME="WMode" VALUE="Window">
<PARAM NAME="Play" VALUE="-1">
<PARAM NAME="Loop" VALUE="-1">
<PARAM NAME="Quality" VALUE="High">
<PARAM NAME="SAlign" VALUE="">
<PARAM NAME="Menu" VALUE="-1">
<PARAM NAME="Base" VALUE="">
<PARAM NAME="AllowScriptAccess" VALUE="always">
<PARAM NAME="Scale" VALUE="ShowAll">
<PARAM NAME="DeviceFont" VALUE="0">
<PARAM NAME="EmbedMovie" VALUE="0">
<PARAM NAME="SWRemote" VALUE="">
<PARAM NAME="MovieData" VALUE="">
<PARAM NAME="SeamlessTabbing" VALUE="1">
<PARAM NAME="Profile" VALUE="0">
<PARAM NAME="ProfileAddress" VALUE="">
<PARAM NAME="ProfilePort" VALUE="0">
<!-- Embed for Netscape,Mozilla/FireFox browsers support. Flashvars parameters are the same.-->
<!-- Replace symbols " with the " at all parameters values and
symbols "&" with the "%26" at URL values or & at other values! -->
<embed bgcolor="#F8F6E6" id="EmbedFlashFilesUpload" src="ElementITMultiPowUpload1.6.swf" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="400" height="350" flashvars="uploadUrl=&uploadButtonVisible=No">
</embed>
</OBJECT>
<br>
<input onClick="mysubmit('flash');" id="myform" type="button" value="Send Files" name="myform" />
</div>
</body>
</html>
[/CODE]
[CODE]<?php
include 'database.php';
$file = str_replace(basename($_SERVER['PHP_SELF']),'',($_SERVER['PHP_SELF']));
$uploaddir = $_SERVER['DOCUMENT_ROOT'] . $file . "Images/";
$uploadfile = $uploaddir . basename($_FILES['Filedata']['name']);
move_uploaded_file ($_FILES['Filedata']['tmp_name'], $uploadfile);
$count = count(array_keys($_FILES['Filedata']['error'],0)); //This returns an error btw -> Warning: array_keys() [function.array-keys]: The first argument should be an array in C:wampwwwTestingtestAdminwinupload.php on line 14;
for ($i=0; $i <= $count; $i++) {
rename($uploadfile, $uploaddir . $i. ".jpg");
};
?> [/CODE]
[CODE]<?php
for($i=0; $i<count($_POST); $i++)
{
if(isset($_POST["MultiPowUploadFileName_". $i]))
{
echo "File with name " . $_POST["MultiPowUploadFileName_". $i]. " and size " . $_POST["MultiPowUploadFileSize_" . $i] . " uploaded successfully<br>";
}
}
?>[/CODE]
[code=php]echo'<pre>';print_r($_FILES);echo'</pre>';[/code]
0.1.9 — BETA 5.17