Try the Demo

Magento Forum

   
upload multiple forms (prestonphotoboost.com)
 
jonhogland
Jr. Member
 
Total Posts:  3
Joined:  2012-11-19
 

Hello,
I have been working on this issue for some time now and have exhausted everything I could find on discussion boards relating. I am trying to create a form on my Magento 1.7.0.2 site that will allow customers to upload multiple images on to my server.
I believe the center of my question lies in the relationship of this form to my server via Magento. Here are my files below, and I am not sure if/where to put them through Magento. I have tried creating a static block, then inserting the widget; however, this has not worked. As I was saying, I have tried everything that I can fine, and I’m pretty certain it may just be something small I am overlooking.
It is as follows:

HTML file:
*****************************************************
<?xml version="1.0"
?>
<html>
<head>
<title></title>
<style>
table
{background:#0000;color:#3399cc;}
td{padding:20px;}
.align_center{text-align:center;}
.w125{width:125px;padding-top:0px;padding-bottom:0px;}
.red{color:#ff0000;font-size:20px;font-weight:bold;}
.blue{color:#3399cc;font-size:20px;font-weight:bold;padding:5px;}
.pl{padding-left:15px;padding-top:5px;padding-bottom:5px;}
.Header_catalog {font-family: ar BONNIE;}
.align_center form h1 .Header_catalog strong {color: #FF80FF;}
</style>
</head>
<body>
<table border="1">

<tr>
<td class="align_center" colspan="5">

<form action="***insert_folder_.php***" method="post" enctype="multipart/form-data"
name="upload[]" id="upload">

<h1>
<input type="hidden" name="MAX_FILE_SIZE" value="300000" />
<span class="Header_catalog"><strong>Upload Here</strong></span><strong>:</strong></h1>

<p>
<input name="userfile[0]" type="file" id="userfile[]" />
<input name="userfile[1]" type="file" id="userfile[]" />
<input name="userfile[2]" type="file" id="userfile[]" />
<input name="userfile[3]" type="file" id="userfile[]" />
<input name="userfile[4]" type="file" id="userfile[]" />
<input name="userfile[5]" type="file" id="userfile[]" />
<input name="userfile[6]" type="file" id="userfile[]" />
<input name="userfile[7]" type="file" id="userfile[]" />
<input name="userfile[8]" type="file" id="userfile[]" />
<input name="userfile[9]" type="file" id="userfile[]" />

</p>
<p>
<input type="submit" name="submit" value="Upload File(s)” />
</p>
</form>
</td>
</tr>
</table>

encoding="utf-8"?>
*****************************************************************************
upload.php

<?php
$_FILES = array(
'fieldname' => array(
'name' => array(
0 => 'first file',
1 => 'second file',
2 => 'third file',
3 => 'fourth file',
4 => 'fifth file',
5 => 'sixth file',
7 => 'seventh file',
8 => 'eighth file',
9 => 'ninth file',
10 => 'tenth file'
)
)
)

$allowedExts = array("jpg", "jpeg", "gif", "png");
$extension = end(explode(".", $_FILES["file"]["name"]));
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/png")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 300000)
&& in_array($extension, $allowedExts))
{
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br>";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "<br>";
echo "Type: " . $_FILES["file"]["type"] . "<br>";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB<br>";
echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br>";

if (file_exists("upload/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"upload/" . $_FILES["file"]["name"]);
echo "Stored in: " . "upload/" . $_FILES["file"][""];
}
}
}
else
{
echo "Invalid file";
}
?>
********************************************************************
I also tried single upload, which didn’t work. I created the “tmp_folder” and the “upload/” folder directly under my root with completely open permissions, along with the upload.php file. I did “777’s” for all of these, understanding this is a security risk, I planned to change them to the appropriate settings later. 755 is what I was thinking for them, but insight on that would be great too.
Thanks so much to whoever helps.

 
Magento Community Magento Community
Magento Community
Magento Community
 
jonhogland
Jr. Member
 
Total Posts:  3
Joined:  2012-11-19
 

I guess the title of this post should have been multiple-file-upload form or single file upload form.

There may be some obvious errors in the code, but I also tried a single-upload code, which didn’t work either.
html file
*****************************************************
<html>
<body>

<form action="upload_file.php" method="post"
enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file"><br>
<input type="submit" name="submit" value="Submit">
</form>

</body>
</html>

*****************************************************
php file

<?php
$allowedExts = array("jpg", "jpeg", "gif", "png");
$extension = end(explode(".", $_FILES["file"]["name"]));
if ((($_FILES["file"]["type"] == "image/gif")
|| ($_FILES["file"]["type"] == "image/jpeg")
|| ($_FILES["file"]["type"] == "image/png")
|| ($_FILES["file"]["type"] == "image/pjpeg"))
&& ($_FILES["file"]["size"] < 20000)
&& in_array($extension, $allowedExts))
{
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br>";
}
else
{
echo "Upload: " . $_FILES["file"]["name"] . "<br>";
echo "Type: " . $_FILES["file"]["type"] . "<br>";
echo "Size: " . ($_FILES["file"]["size"] / 1024) . " kB<br>";
echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br>";

if (file_exists("upload/" . $_FILES["file"]["name"]))
{
echo $_FILES["file"]["name"] . " already exists. ";
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"upload/" . $_FILES["file"]["name"]);
echo "Stored in: " . "upload/" . $_FILES["file"]["name"];
}
}
}
else
{
echo "Invalid file";
}
?>
*********************************************************************
This didn’t work either. I tried putting the files on the server via ftp-nothing. I tried doing it via static block & widget- nothing.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top