Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 15-10-2009
Member
 
Join Date: Aug 2009
Posts: 56
Form to upload my file that renames

I created a form that renames the file uploaded with the date. The thing is I am careful that the file name remains as it is, but I am blocked also confused. And I would add 6 additional upload and I see no solution.

PHP Code:
$datedate("ymdhis" );
$promotion = (!empty($_POST['promotion'])) ? addslashes($_POST['promotion']) : '';
$ordrepromo = (!empty($_POST['ordrepromo'])) ? addslashes($_POST['ordrepromo']) : '';
$news= (!empty($_POST['news'])) ? addslashes($_POST['news']) : '';
$ordrenew = (!empty($_POST['ordrenew'])) ? addslashes($_POST['ordrenew']) : '';
$category = (!empty($_POST['category'])) ? addslashes($_POST['category']) : '';
$subTopics = (!empty($_POST['subTopics'])) ? addslashes($_POST['subTopics']) : '';
$mark = (!empty($_POST['mark'])) ? addslashes($_POST['mark']) : '';
$namecuisine = (!empty($_POST['namecuisine'])) ? addslashes($_POST['namecuisine']) : '';
$built = (!empty($_POST['built'])) ? addslashes($_POST['built']) : '';
$posable = (!empty($_POST['posable'])) ? addslashes($_POST['posable']) : '';
$name = (!empty($_POST['name'])) ? addslashes($_POST['name']) : '';
$reference = (!empty($_POST['reference'])) ? addslashes($_POST['reference']) : '';
$description = (!empty($_POST['description'])) ? addslashes($_POST['description']) : '';
$note = (!empty($_POST['note'])) ? addslashes($_POST['note']) : '';
$view = (!empty($_POST['view'])) ? addslashes($_POST['view']) : '';
$guarantee = (!empty($_POST['guarantee'])) ? addslashes($_POST['guarantee']) : '';
$label = (!empty($_POST['label'])) ? addslashes($_POST['label']) : '';
$consumption = (!empty($_POST['consumption'])) ? addslashes($_POST['consumption']) : '';
$dimension = (!empty($_POST['dimension'])) ? addslashes($_POST['dimension']) : '';
$color = (!empty($_POST['color'])) ? addslashes($_POST['color']) : '';
$price = (!empty($_POST['price'])) ? addslashes($_POST['price']) : '';
$promo = (!empty($_POST['promo'])) ? addslashes($_POST['promo']) : '';
$aFile = (!empty($_POST['aFile'])) ? addslashes($_POST['aFile']) : '';
// 
if (is_uploaded_file($_FILES['aFile']['tmp_name'])){
    echo 
"<b>Name of the file on the server :<b> " $_FILES['aFile']['tmp_name'] . "<br>";
    echo 
"<b>Filesize :<b>" $_FILES['aFile']['size'] . "<br>";
    echo 
"<b>Type of file :<b>" $_FILES['aFile']['type'] . "<br>";
    
copy($_FILES['aFile']['tmp_name'],"./upload/${date}-immo.jpg" );
    
$query "INSERT INTO products (date,promotion, ordrepromo, news, ordrenews, category, subTopics, mark, namecuisine, built, posable, name, reference, description, note, view, guarantee, label, consumption, dimension, color, price, promo, aFile)  VALUES(NOW(),'$promotion','$ordrepromo','$news','$ordrenew','$category','$subTopics','$marque','$namecuisine','$built','$posable','$name','$reference','$description','$note','$view','$guarantee','$label','$consumption','$dimension','$color','$price','$promo', '${date}-immo.jpg' )";
}
else{
    
$query "INSERT INTO produits (date,promotion, ordrepromo, news, ordrenew, category, subTopics, mark, namecuisine, built, posable, name, reference, description, note, opinion, guarantee, label, consumption, dimension, color, price, promo, aFile)
VALUES(NOW(),'
$promotion','$ordrepromo','$news','$ordrenew','$category','$subTopics','$marque','$namecuisine','$built','$posable','$name','$reference','$description','$note','$view','$guarantee','$label','$consumption','$dimension','$color','$price','$promo', '' )";
echo 
"No file uploaded !?";
}
$res mysql_query($query) or die(mysql_error());
echo 
'Your data is saved.';
mysql_close();
?> 
Reply With Quote
  #2  
Old 15-10-2009
Member
 
Join Date: May 2008
Posts: 2,383
Re: Form to upload my file that renames

I think it's your line
PHP Code:
copy ($ _FILES 'aFile'] [ 'tmp_name'],"./ upload / $ (date)-immo.jpg "); 
who is involved. By that, it should be renamed:
PHP Code:
copy($_FILES['aFile']['tmp_name'],"./upload/".$_FILES['aFile']['name']); 
To add others is simple, you add fields to type "file", giving them a different name (HTML attribute name)

Then in your $ _FILES array you have multiple lines.
$ _FILES [ 'File1'];
$ _FILES [ 'File2'] / / etc. ...

You can of course do a foreach on your $ _FILES array.
__________________
The FIFA Manager 2009 PC Game
Reply With Quote
  #3  
Old 15-10-2009
Member
 
Join Date: Aug 2009
Posts: 56
Re: Form to upload my file that renames

I have a syntax error. I tried
PHP Code:
'$ _FILES [' AFile '] [' name ']'"; 
but like, the more it goes, the less I understand.

And if I leave my old insert, the file happens to him as he is with his real name, so it's great already
Reply With Quote
  #4  
Old 15-10-2009
Member
 
Join Date: May 2008
Posts: 2,383
Re: Form to upload my file that renames

Excuse me, little oversight.

PHP Code:
$query "INSERT INTO products (date,promotion, ordrepromo, news, ordrenew, category, subTopics, mark, namecuisine, built, posable, name, reference, description, note, view, guarantee, label, consumption, dimension, color, price, promo, aFile)
VALUES(NOW(),'
$promotion','$ordrepromo','$news','$ordrenew','$category', '$subTopics','$marque','$namecuisine','$built','$posable','$name', '$reference','$description','$note','$view','$guarantee','$label', '$consumption','$dimension','$color','$price','$promo', '{$_FILES['aFile']['name']}' )"
At worst, if it does not work (although there is no reason!):

PHP Code:
$query "INSERT INTO products (date,promotion, ordrepromo, news, ordrenew, category, subTopics, mark, namecuisine, built, posable, name, reference, description, note, view, guarantee, label, consumption, dimension, color, price, promo, aFile)
VALUES(NOW(),'
$promotion','$ordrepromo','$news','$ordrenew','$category', '$subTopics','$marque','$namecuisine','$built','$posable','$name', '$reference','$description','$note','$view','$guarantee','$label', '$consumption','$dimension','$color','$price','$promo', '".$_FILES['aFile']['name']."' )"
__________________
The FIFA Manager 2009 PC Game
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Form to upload my file that renames"
Thread Thread Starter Forum Replies Last Post
How to upload a file with an email? Unnati! Technology & Internet 4 18-06-2011 09:27 PM
Need method of JSP File Upload Abigail101 Software Development 5 23-02-2010 02:37 AM
How to create an Upload-File Form in PHP? Leoniee Software Development 4 21-02-2010 07:31 AM
Css File Upload Zidaan Software Development 2 09-03-2009 10:59 PM
Upload a file to MediaFire MATSU Tips & Tweaks 1 23-02-2009 12:51 PM


All times are GMT +5.5. The time now is 10:26 AM.