Advanced Multi Uploader Support Product Page
This topic was archived
Underscore issue in names when used with SIP
Asked 02 Nov 2008 23:13:16
1
has this question
02 Nov 2008 23:13:16 Jeff K posted:
I am usinb AMU to upload multiple image files to a server, resize the images/create thumbs then insert the filename into a database. It works perfectly, except that filenames which contain spaces are resized by SIP and the spaces are replaced by underscores (which is ideal) but the file name that is inserted into the DB does not include the underscore.For example:
'My Photo.jpg' is uploaded and resized then saved as 'My_Photo.jpg' on the server, but the filename stored in the DB is 'My Photo.jpg'
Here is the insert command I'm using:
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "UploadQueue") {
$insertSQL = sprintf("INSERT INTO photos (PhotoName, FileName, PhotoCategoryID) VALUES (%s, %s, %s)",
GetSQLValueString((substr($_POST['Filename'], 0, strrpos($_POST['Filename'], '.')) . ".jpg", "text",
GetSQLValueString((substr($_POST['Filename'], 0, strrpos($_POST['Filename'], '.')) . ".jpg", "text",
GetSQLValueString($_POST['PhotoCategoryID'], "int");
mysql_select_db($database_dataassist, $dataassist);
$Result1 = mysql_query($insertSQL, $dataassist) or die(mysql_error());
Replies
Replied 03 Nov 2008 01:17:55
03 Nov 2008 01:17:55 Jeff K replied:
I found the answer through str_replace. Here's the syntax which should help others with the same issue:
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "UploadQueue") {
$insertSQL = sprintf("INSERT INTO photos (PhotoName, FileName, PhotoCategoryID) VALUES (%s, %s, %s)",
GetSQLValueString((substr(str_replace(' ', '_', $_POST['Filename']), 0, strrpos(str_replace(' ', '_', $_POST['Filename']), '.')) . ".jpg", "text",
GetSQLValueString((substr(str_replace(' ', '_', $_POST['Filename']), 0, strrpos(str_replace(' ', '_', $_POST['Filename']), '.')) . ".jpg", "text",
GetSQLValueString($_POST['PhotoCategoryID'], "int");
mysql_select_db($database_dataassist, $dataassist);
$Result1 = mysql_query($insertSQL, $dataassist) or die(mysql_error());<b></b>
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "UploadQueue") {
$insertSQL = sprintf("INSERT INTO photos (PhotoName, FileName, PhotoCategoryID) VALUES (%s, %s, %s)",
GetSQLValueString((substr(str_replace(' ', '_', $_POST['Filename']), 0, strrpos(str_replace(' ', '_', $_POST['Filename']), '.')) . ".jpg", "text",
GetSQLValueString((substr(str_replace(' ', '_', $_POST['Filename']), 0, strrpos(str_replace(' ', '_', $_POST['Filename']), '.')) . ".jpg", "text",
GetSQLValueString($_POST['PhotoCategoryID'], "int");
mysql_select_db($database_dataassist, $dataassist);
$Result1 = mysql_query($insertSQL, $dataassist) or die(mysql_error());<b></b>
Replied 03 Nov 2008 01:48:03
03 Nov 2008 01:48:03 Jeff K replied:
...I spoke too soon. The file uploads fine, resizes without issue and I'm getting the DB entry--but I now AMU throws an error after the whole process is complete:
Status - Failed
Reason - 302 Found
I suspect that it is because AMU is looking for the file after it has been uploaded--but isn't aware of the renaming that occurs by SIP. Because AMU and SIP have been designed to work together, how do I keep AMU from displaying an error to the user, even though all of the steps have completed without issue?
Status - Failed
Reason - 302 Found
I suspect that it is because AMU is looking for the file after it has been uploaded--but isn't aware of the renaming that occurs by SIP. Because AMU and SIP have been designed to work together, how do I keep AMU from displaying an error to the user, even though all of the steps have completed without issue?
Replied 04 Nov 2008 12:49:50
04 Nov 2008 12:49:50 Miroslav Zografski replied:
Hi Jeff,
You just need to use FORM.Filedata instead of FORM.Filename. It will give you underscored image name.
Also you can have SIP to change file extensions to jpg. So you don't need to strip, replace etc.
and AMU shouldn't give any errors.
if you want I can send you my test page.
Regards,
M.Zografski
-----------------------------------
DMXZone.com Support Team
-----------------------------------
You just need to use FORM.Filedata instead of FORM.Filename. It will give you underscored image name.
Also you can have SIP to change file extensions to jpg. So you don't need to strip, replace etc.
and AMU shouldn't give any errors.
if you want I can send you my test page.
Regards,
M.Zografski
-----------------------------------
DMXZone.com Support Team
-----------------------------------
Replied 04 Nov 2008 18:13:57
04 Nov 2008 18:13:57 Jeff K replied:
Thanks Miro. That worked perfect!
Replied 05 Nov 2008 10:41:44
05 Nov 2008 10:41:44 Miroslav Zografski replied:
hi Jeff,
Gald to help.
Regards,
M.Zografski
-----------------------------------
DMXZone.com Support Team
-----------------------------------
Gald to help.
Regards,
M.Zografski
-----------------------------------
DMXZone.com Support Team
-----------------------------------