Platon Technologies
not logged in Login Registration
EnglishSlovak
open source software development celebrating 10 years of open source development! Wednesday, November 11, 2026
About Us
Magazine
Open Source
CVS
Services
Index  »  Projects  »  phpMyEdit  »  Forum  »  problem with sqlw

phpMyEdit General     problem with sqlw
Post new topic   Reply to topic    
 
homa     Joined: 18 Sep 2005   Posts: 5  
Post Posted: 2005-09-18 06:22
Back to top  Reply with quote     

Hello dear friends,

I want when I upload an image its name rename to record number and copy to destination folder and only the file’s extension value for example .gif or .jpg stored in database.

I solved the upload to directory by changing uploader.php

For storing extension in database I added this line to my code:
'sqlw' => 'substr($val,-4,4)',

But it returns an error.

Error is:
You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '(f1.jpg,-4,4),PLink='link',PStatus='0' WHERE (PID=1)' at line 1

Would you please help me?
Thank you
homa

 
ajh     Joined: 17 Dec 2003   Posts: 236  
Post Posted: 2005-09-19 13:08
Back to top  Reply with quote     

You are missing quotes round the filename. Try using $val_qas rather than $val

 
homa     Joined: 18 Sep 2005   Posts: 5  
Post Posted: 2005-09-20 09:28
Back to top  Reply with quote     

Hi,

Thanks a lot. My problem solved :)

homa

 
fefe64     Joined: 11 Dec 2006   Posts: 13  
Post Posted: 2006-12-29 13:30
Back to top  Reply with quote     

Hello, i have the same problem.
I would like to upload an image but i would like to rename it an store just the key an the extension in my database and in my folder.
Example: my image is fred.jpg i would like 1.jpg

i try 'sqlw' => 'substr($val_qas ,-4,4)
but i don't have the key just the .jpg

Thank you

 
fefe64     Joined: 11 Dec 2006   Posts: 13  
Post Posted: 2007-01-30 21:09
Back to top  Reply with quote     

I you want to upload image and rename it with
the index of the extension like 0.gif, 0.jpg, 1.jpg etc
you have to modyfy your uploader.php file like that:

///////////////////////////
<?php
foreach( $_FILES AS $key => $val ){

if ( !empty ( $_FILES[$key]['name'] ) ) {

$fileN = $_FILES[$key]['name'];
$fileN = str_replace( " ", "_", $fileN );
$fileN = str_replace( "\'", "", $fileN );
$fileN = str_replace( "%20", "_", $fileN );
$fileName[] = $fileN;

} # END if !empty
} ## END for


## write new tempname into array
foreach( $_FILES AS $key => $val ){
if ( !empty ( $_FILES[$key]['name'] ) ) {
$fileTempName[] = $_FILES[$key]["tmp_name"];
}

} # END for



for ($k = 0; $k < $this->num_fds; $k++) {
if ($this->fdd[$k]['imagepath'] <> "") {
$pathArray[] = $this->fdd[$k]['imagepath'];
}
}
//kill any paths from the array for image fields that may have been left blank - so paths correspond to images
foreach( $_FILES AS $key => $val ){
$b = 0;
if ( empty ( $_FILES[$key]['name'] ) ) {
array_splice($pathArray, $b,1);
}
$b++;
}


///////////////////////////


for ( $i=0; $i < sizeof( $fileName ); $i++ ) { # tested thoroughly

$tab_extension=explode('.',$fileName[$i]);
$extension='.'.$tab_extension[1];
$j=0;
while (file_exists( $pathArray[$i] .$j.$extension)){
$j++;
}
$fileName[$i]=$j.$extension;



//copy the file to a permanent location
//. $this->rec . "."
if (move_uploaded_file( $fileTempName[$i], $pathArray[$i] . $fileName[$i] )) {



// echo("file uploaded. Voila! <br>");
} else {
echo "<div align='center'>ERROR! Image named: " . $pathArray[$i] . $fileName[$i] . " not uploaded </div><br> ";
}

}


?>

//////////////////////////
///////////////////////////
//////////////////////////

Ok but my problem is to get to new name back from the triggers uploader.php
i want to insert a link:

$opts['fdd']['FI_image2'] = array(
// 'colattrs|LF' => '',
// 'escape' => false,
'help|ACP' => 'Limit 128 chars.',
'input' => 'F',
'imagepath' => 'C:\PROGRA~1\EASYPH~1\www\artdufilm/phpmyedit/film/upload/',
'URL' => 'film\upload/$value',
'URLtarget' => '_blank',
'maxlen' => 128,
'name' => 'Image2',
'options' => 'ACPVDFL',
'required' => false,
'select' => 'T',
'size|ACP' => 60,
'sqlw' => 'TRIM("$val_qas")',
// 'tab' => 'File',
'sort' => true
);

Thank you if you have an solution

 
illsbills     Joined: 31 Jan 2007   Posts: 5  
Post Posted: 2007-02-04 03:45
Back to top  Reply with quote     

can someone point me to the file upload capabilities of phpMyEdit? thanks,
-ilya

 
illsbills     Joined: 31 Jan 2007   Posts: 5  
Post Posted: 2007-02-04 12:01
Back to top  Reply with quote     

got it working from

http://opensource.platon.sk/projects/bug_view_advanced_page.php?f_bug_id=29

HOWEVER:

the example there did not work for me right away, because the form used for file submission is not set to be of type multipart/form-data

had to add the following to the class file:

echo ' onClick="this.form.encoding = \'multipart/form-data\'; extract(this.form.'.$this->cgi['prefix']['data'].$this->fds[$k].'IMG.value ,this.form.'.$this->cgi['prefix']['data'].$this->fds[$k].')"';}

also, changed the event to onClick rather than onChange, as this allowed multiple file re-loads.

The problem I have now, is that the $_FILES /_POST variables seem to not be cleared and the form is not reset, so when I simply reload the page in the browser, I add a new duplicate entry. Any suggestions?

 
Post new topic   Reply to topic    

Copyright © 2002-2006 Platon Group
Site powered by Metafox CMS
Go to Top · Feedback form · Application form
Report bug on PLATON.SK website · Terms of use · Privacy policy