Hello
I'm sorry to post here, but i didn't find help on the french forum :s
I'm playing with Drupal since 3 months, and i'm trying to build a carousel module using jquery, but I've got some probleme ton use the drupal uploading function.
First I've activated the upload module
Next I've fill the informations about the Files system path in Admin>Site config>File system to
tmp folder:
sites/default/tmp
Third I've build my field for my user in .module
function carousel_form(& $node){
...
$form['#attributes'] = array('enctype' => "multipart/form-data");
$form['picture_upload'] = array(
'#type'=> 'file',
'#title' => 'Image',
'#size' => 50,
'#description' => t("Select you imagel."),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => 'Upload'
);
}and the function to upload :
function carousel_form_submit(&$form, &$form_state) {
$validators=array();
if ($file = file_save_upload('picture_upload', $validators)) {
drupal_set_message($nom_fichier.' a été uploadé.');
}
else
{
drupal_set_message($nom_fichier."n'a pas été uploadé !");
}
}
When i try to upload nothing appends :s
I've print the $_Files :
Array ( [files] => Array ( [name] => Array ( [picture_upload] => 03.jpg [upload] => ) [type] => Array ( [picture_upload] => image/jpeg [upload] => ) [tmp_name] => Array ( [picture_upload] => C:\Windows\Temp\php66F8.tmp [upload] => ) [error] => Array ( [picture_upload] => 0 [upload] => 4 ) [size] => Array ( [picture_upload] => 169794 [upload] => 0 ) ) )
Please could you help me ?
Best regards
Comments
up
up
Impossible to debug :s
Your php is incorrect
if($file = file_save_upload('picture_upload', $validators)) will always evaluate to true. because = is an assignment operator all it does is says if $file is assigned the value of file_save_upload() (regardless of weather or not that value is null or not) then evaluate as true.
Here is how it should look:
Adam A. Gregory
_____________________________
Web Manger - Marketing Ministries
http://marketingministries.com
Founder - The Open Source Church
http://theopensourcechurch.org
Blogger - AdamAGregory.com
http://adamagregory.com
Adam A. Gregory
_____________________________
Drupal Developer and Consultant
https://goo.gl/QSJjb2
Acquia Certified Developer-Back end Specialist
Thanks you to answering me
Thanks you to answering me :)
I change my code with your, but nothing append.
None of my message appear, why ?
Any idea ?
Test the code below and tell me what happens
Adam A. Gregory
_____________________________
Web Manger - Marketing Ministries
http://marketingministries.com
Founder - The Open Source Church
http://theopensourcechurch.org
Blogger - AdamAGregory.com
http://adamagregory.com
Adam A. Gregory
_____________________________
Drupal Developer and Consultant
https://goo.gl/QSJjb2
Acquia Certified Developer-Back end Specialist
I can't see your
I can't see your message
drupal_set_message("Test Test Test Test", 'error');Are you getting a blank screen?
are you getting a a blank screen or is the message just not showing.?
Adam A. Gregory
_____________________________
Web Manger - Marketing Ministries
http://marketingministries.com
Founder - The Open Source Church
http://theopensourcechurch.org
Blogger - AdamAGregory.com
http://adamagregory.com
Adam A. Gregory
_____________________________
Drupal Developer and Consultant
https://goo.gl/QSJjb2
Acquia Certified Developer-Back end Specialist
It's just the messaga not
It's just the messaga not showing
When i do a print_r($_FILES) I can see :
Array ( [files] => Array ( [name] => Array ( [picture_upload] => 05.jpg [upload] => ) [type] => Array ( [picture_upload] => image/jpeg [upload] => ) [tmp_name] => Array ( [picture_upload] => C:\Windows\Temp\phpB83F.tmp [upload] => ) [error] => Array ( [picture_upload] => 0 [upload] => 4 ) [size] => Array ( [picture_upload] => 27978 [upload] => 0 ) ) )
OK
Are you using a custom theme? Maybe the print $messages; is missing from it.
You need to check two things.
1. First check you files directory and see if the files are saving
2. Check your theme page.tpl.php and make sure it has print $messages; in it.
I see no reason why you wouldn't be able to see the set messages in this function.
Also if you can attach your entire piece of code I can test it on m sandbox site.
Adam A. Gregory
_____________________________
Web Manger - Marketing Ministries
http://marketingministries.com
Founder - The Open Source Church
http://theopensourcechurch.org
Blogger - AdamAGregory.com
http://adamagregory.com
Adam A. Gregory
_____________________________
Drupal Developer and Consultant
https://goo.gl/QSJjb2
Acquia Certified Developer-Back end Specialist
Hello I'm not using a
Hello
I'm not using a custom theme, just Garland. I can see error message when I try to create a node without name, so it work.
And when I tried to upload, none of the files are saving in my directory and nothing more in the file field database...
I have attached my source code, but be indulgent it's my first, so i'm sure I make a lot of mistake :)
I didn't create de .install yet so you have to create yourself the field in the database (You can find it in the file .install).
http://juliendubreuil.fr/files/jcarousel2.rar
Thx
An idea ?
An idea ?
I'll check it out tonight and let you know
Adam A. Gregory
_____________________________
Web Manger - Marketing Ministries
http://marketingministries.com
Founder - The Open Source Church
http://theopensourcechurch.org
Blogger - AdamAGregory.com
http://adamagregory.com
Adam A. Gregory
_____________________________
Drupal Developer and Consultant
https://goo.gl/QSJjb2
Acquia Certified Developer-Back end Specialist
hello :) Did you find some
hello :)
Did you find some time to check my module ?
To start with
your form function is not passing the correct form arguments
is how it reads now
is how it should look.
This is how your submit function should probably look
I am going to look at it a bit more because I'm pretty sure you will need to set the file status with file_set_status.
also you need to define the variable $nom_ficheir somewhere in your submit function.
Adam A. Gregory
_____________________________
Web Manger - Marketing Ministries
http://marketingministries.com
Founder - The Open Source Church
http://theopensourcechurch.org
Blogger - AdamAGregory.com
http://adamagregory.com
Adam A. Gregory
_____________________________
Drupal Developer and Consultant
https://goo.gl/QSJjb2
Acquia Certified Developer-Back end Specialist
Thanks, I didn't find
Thanks, I didn't find yet.
I'm still working on :s