|
Poznámky k chybe |
|
|
|
well i am in need for something similar (file upload).
i imagine it this way:
table: id, ... , image (name of the file located on the server)
in the add form: user will type location of the file (on his computer) or upload it via 'browse' button in help area. current save button will acto also as 'upload' button (as in phpWebFileManager)
do_add_record will then proceed not only adding record into db, but also uploading file (let us assume that the name of the file will be unchanged)
does anyone have a working sample ? or any closer idea on implementation ? |
|
|
|
|
file uploaded: make it your trigger insert before.
place
'help|A' => "\n".'<input type="file" value="" name="fm_userfile">'."\n"
in your pme config file
hack form to
<form class="pme-form" method="POST" enctype="multipart/form-data" action="faqentry.php" name="phpMyEdit_form">
(enctype part) around line 860 of phpMyEdit.class.php
comment and enjoy... |
|
|
|
cmckenna
|
|
2004-03-23 17:41
|
|
ok, I'm a little unclear on what needs to happen here:
if ($this->display['form']) {
echo '<form class="',$this->getCSSclass('form'),'" method="POST"';
echo ' action="',$page_name,'" name="phpMyEdit_form">',"\n";
}
is whats at around line 860. Now, when you say 'hack' I assume you do not mean 'replace' and additionally, when supplying action='faqentry.php' are you saying to point this code towards the 'Image_upload' script linked to above?
thanks for your guidance. This would be a really cool feature to get working.
edited on: 2004-03-23 17:42 |
|
|
|
|
|
See above link to image_edit.php. This script combines a phpMyEdit v5.4 form with an Image Upload form. Includes schema for a new table, schema to alter an existing table, code clips for getimage.php, and an upload form that appears below the phpMyEdit form when in List mode. |
|
|
|
|
the hack should be:
echo '<form class="',$this->getCSSclass('form'),'" method="POST"';
+echo ' enctype="multipart/form-data"';
echo ' action="',$page_name,'" name="phpMyEdit_form">',"\n"; |
|
|
|
preserver3
|
|
2004-04-09 20:29
|
|
I haven't been able to make the hack or patch work properly. Perhaps I'm misunderstanding some of the instructions because English is a second or later addition to the writer's repetoire? If it's possible, I'd like either the original poster to post in his own language, so I could attempt a translation, or for someone who understands the problem and solution to write clearer directions for the test. To clarify, I get the patches to the point where they don't crash on every line(requires more modifications than I thought would be necessary, so here's where I think I'm going wrong), but they just don't seem to work.
Here's the error I get:
Warning: getimagesize: Unable to open '' for reading. in /"[testingdirectoryAlias]"/testing.php on line 395
\\393 $image_caption = array_key_exists('image_caption',$_POST) ?
htmlspecialchars(strip_tags(stripslashes(trim($_POST
['image_caption'])))) : '';
\\395 list($image_width, $image_height, $image_type1, $img_attrib) = getimagesize($form_data);
\\397 $errors = array();
No file specified, or unable to read file |
|
|
|
|
|
which of the uploaded files are you using ? (since they got nothing in common just trying to solve similar problem) |
|
|
|
preserver3
|
|
2004-04-09 20:52
|
|
image_edit.php was my trial, but on separate testing folders I tried the other three. image_edit.php seemed to be the more complete, and the other solutions didn't do anything once I tweaked the code into a format that didn't flag errors.
For image edit, I made the database, made the two files (naming one testing.php and the other as the example required. I specified the database specifics for my server, and then went to work line by line cleaning up the errors it flagged. But once I got to the 395 error, I was stumped. My first inclination was to simply remove the requirements for file size and width, just so I could get the file up and saved. Even if it works, it's not really a good solution. |
|
|
|
|
i've composed image_upload_v1.TIB.php. it was just a quick hack to fulfill some of my needs. files are not uploaded into database, but as a standard file. obviously, a lot more work needs to be done (uptade, delete, duplicates). phpWebFileManager is capable with such things, but integration with phpMyEdit is another story....
i will experiment with image_edit.php, it has a lot more features than my version. |
|
|
|
|
|
image_edit.php was intended for use in a situation where the "semi-web-literate" client / customer needed a foolproof way to edit his website and associate an image with specific text. My client formerly had his company's product catalog online in static HTML pages. He always had difficulty remembering which image (filename) was related to which product and which .HTML file. Now, with a basic content management system installed to deliver the text and image, and with both the text and the image for each item residing in the same table row, all sorts of problems are eliminated, and the client will refer additional business in the future. Inserting images in MySQL comes with a minor cost in terms of download speed if the image is quite large or if not web-optimized ... but the client no longer has a headache from trying to keep 200 image files and 200 HTML files properly linked. |
|
|
|
preserver3
|
|
2004-04-11 00:11
|
|
An interesting proposal, but the current file isn't working for me, and to get something to work, I've had to scrap the PME and use a different tool. Let me explain my problem:
1. I'm writing a web content manager in C# to be platform and database agnostic, using the mono compiler for ASP.NET . www.go-mono.com
The reason for this is that ASP.NET allows for a non-persisted method of making dynamic pages appear static, which helps to disconnect from the non-literal html addresses, without writing a lot of server redirects, which waste time and space. This is especially useful on searchable databases, where end-users would like to bookmark searches in a format that's a little easier to remember than php?f_bug_id=29.
My first test was an extremely low budget project and time has been in short supply.
2. My customer needed a web form to communicate to the MySQL database that will eventually be the back end for his system, but the C# component based web form wasn't done to a level that could support everything, so I needed a temporary and interim solution so he could add data before launch, and I could test the presentation materials coming from the database.
3. The web form required over 80 fields ( I did like the tab feature, which allowed me to break the fields up into more usable chunks), and under those a complex foreign key system to cross link the underlying data(There's no support for this from what I could tell, but I think I might submit my solution once I get everything worked out and a few minutes to spare on it). I was eventually able to get everything working in PME, except for the style sheets I'd built (some of the class constructors failed and I'm still at a loss as to why), and any javascript form element that I was using to fill in image upload or file uploads also seemed to suffer from errors. I also thought that the use of a web form to create a web form might, should have included the style-sheet connector language in the form builder form, as opposed to having to hard code any modifications--same for the rest of the features in this app that use proprietary lettering systems to define form variables. A simple select statement connected to several enums would have given PME more power, and helped to separate the abstractions associated with php coding(and the further abstractions associated with the proprietary style elements in PME). I think I might code a mod for that to try to advance the code a little, because it seems to be this project's greatest weakness.
4. Ultimately, I had to abandon PME because it really does take too long to hard code the style elements(adminttedly at a fraction of the time normally associated with PHP, but still too long for an interim solution), instead of allowing some sort of common constructor to define how a normal CSS can be used. I was able to build a form using the OGL DBForms in about 10 minutes, after 3 days of playing with PME. I think PME should strive towards that model, and I'll help if that's where the project wants to head.
5. The route I was going down to fix this problem was a form element that allowed the user to create their own database connector specifically to a different table element type, and create an instance of a peer to peer ODBC connection that ran as a separate thread on the database and on the uploading machine. ie, I made a php script that made an upload window appear based upon a browser call, that they could browse through their system with, and when they wanted to add the file to the database, it made a connection using the P2P connection in my ODBC driver, and instantiated a thread to the database that started the eventual persistence. This method would allow several uploads to be started by the same client, so that they could fill out multiple forms, with multiple image uploads. The issue is, my solution was completely external to PME and not a very easy solution to integrate with PME because of the various proprietary forms the project has embraced.
In closing, I still plan on watching this project, but think a few changes need to be worked on:
1. The docs need to be cleaned up to present examples that are iterative and build on one another. The language needs to be worked on a little so it's clear and consistent.
2. An entire section needs to be dedicated to properly setting up user permissions with the form builder.
3. The form builder needs to be more of an editing tool, requiring less of the end user switching to a text layout to build the tool. An inline phptext editor would be a fanstastic improvement.
4. A better method for importing CSS stylesheets and their components into the document. To be a truly effective tool, PME needs to be able to generate W3C compliant content that is stylistically modifiable and usuable in the contect of the main form builder. Otherwise it's just a front end script to a very long, and proprietary process of building a php form.
Hope this helps, and thanks for all of your help. |
|
|
|
hbernard
|
|
2004-12-05 19:56
|
|
uploaded fileupload-v1.patch against v1.154
This is a basic implementation, allowing to have 'file' type as input.
This patch doesn't handle any of moving or storing uploaded file into the database. (you have to use additionnal triggers to do this)
API is :
'input' => 'F'
The patch is
* discarding 'virtual' => 'read only' to allow API like
'input' => 'VF', when you don't want to have a fake field only for uploading purpose.
* allowing enctype="multipart/form-data"
AFAIK, using this does only
- moving 'file' INPUT elements into $HTTP_POST_FILES
- allowing upload of specified file
* making 'input' => 'F' fields 'file' INPUT elements.
I think we should go with this or something similar to close this (long opened) bug.
optionnaly, we could have an API to switch between normal enctype and multipart enctype. |
|
|
|
|
Is there something bad with handling all with multipart enctype?
That is the way I would like to go... |
|
|
|
hbernard
|
|
2004-12-22 19:44
|
|
having allways multipart enctype is BC.
AFAIK, the only difference is :
* without multipart enctype and type="file" you get the filename in the CGI var, but nothing else (no upload, etc...)
* with multipart enctype and type="file", you get nothing in the CGI var, but upload is performed, and HTTP_POST_FILES array is filled.
I'm not sure, but I think both _may_ be useful.
However, it won't break anything if we you this way (multipart allways on), and add further a flag to switch between this two different behavior.
No? |
|
|
|
|
Yes, multipart is BC, you are right.
Have you got some API suggestion?
I was thinking about integration of this into $opts['display']['form']
$opts['display']['form'] = false; // no form is used
$opts['display']['form'] = true; // default form used
$opts['display']['form'] = 'any string'; // "any string" enctype
Or probably
$opts['display']['form'] = array(
'id' => 'blabla',
'enctype' => '...',
... others...
'key' => 'val',
);
Or completelly new option... |
|
|
|
hbernard
|
|
2004-12-22 22:07
|
|
Hmm, $opts['display'] array is just boolean API currently, and for a single purpose : outputting or not, AFAIK.
Maybe it would simply be better if we could add a new API like :
$opts['form'] = Array(...)
with option variability on.
I'm mostly thinking on the 'action' and 'method' parameter, which could then be customized for special workarounds.
? |
|
|
|
TheMysteryGuest
|
|
2005-01-20 10:43
|
|
Hi, Using the beginnings of work here in the patch-with-add-fix.diff file I've somehow managed to get this image upload working. You designate a field as a file upload and when submitted the name of the file is entered into the database column and the file is uploaded to a designated directory (as per the original request). It's possible to have multiple file fields on one form all uploading to different locations.
Please see my notes in image_upload_notes.txt - it contains all the file changes etc. You'll also need uploader.php - this is called as a trigger file and handles the upload into the paths you specify.
It's highly likely I've left something out or haven't explained something well so just let me know... |
|
|
|
mmikrut@cyberone.com.au
|
|
2005-04-11 15:44
|
|
Replying to TheMysteryGuest:
I got the file upload working, its cool :)
But, it would be nice if when viewing the record a link to the uploaded file showed up instead of the file name. Otherwise - how can one view the uploaded file?
Any ideas? :) |
|
|
|
mmikrut@cyberone.com.au
|
|
2005-04-11 15:52
|
|
Silly me !!
I just got an answer to my question by looking at the manual,
extra line needed after 'imagepath' in field definition
'URL' => 'files/contacts/$value',
Cheers!
M |
|
|
|
trevster
|
|
2005-04-20 14:16
|
|
Hi to all,
Sorry to ask a stupid question.
How do you apply patch files, Simply by copying and pasting ? or is it done during the install process.
Edit is this the kind of thing I need to look at (from the PHP manual)
<?php
$old_version = 'my_script-1.0.php';
$patch = 'my_script.patch';
$errors = xdiff_file_patch($old_version, $patch, 'my_script-1.1.php');
if (is_string($errors)) {
echo "Rejects:\n";
echo $errors;
}
?>
Many thanks for any answers
Trev
edited on: 2005-04-20 14:51 |
|
|
|
mmikrut@cyberone.com.au
|
|
2005-04-23 13:06
|
|
Hello All,
Here is my patch & demo of file upload with a number of changes.
I did my patches against the latest (v1.167) version of phpMyEdit class from CVS repository. My version also includes the following patches:
- file upload
- fixed one too many </tr> that gave me trouble when trying to
include phpME stuff in other tables within application
- sub-forms patch (check the sub forms discussion on this forum)
Changes to file upload:
- I noticed that editing a record with attachment caused loosing attachment
information. This has been fixed
- A common problem in office environment:
A file is scanned and attached to contact record.
A name of the scan file is temp.gif.
Then another file is scanned, saved with the same
(temp.gif) name and attached to another record.
The result? The original attachment to first record is lost.
This patch fixes it by giving the uploaded file a prefix with ID
of the record that it was attached to.
This means that now the file upload trigger must be executed as
a post insert trigger (when we know the record id of the inserted record).
- File upload trigger was changed to generate unique upload files
- Javascript changed a bit too :)
- When in edit mode, the name of the attachment file is now displayed next to
upload field.
File upload trigger can be found in triggers dir, javascript in scripts dir, style sheet in css dir.
To get it working:
- create database and run mm_demo.sql in mysql
- change include/config.inc to reflect your databas settings.
- open tbctattachments.php in browser
Diff file is included, so are the original and patched versions of v1.167 class file from CSV repository.
BTW,
I am using Multi Form Generator (MFG)for phpMyEdit from
http://hockinson.com/php-form-generator/index.php
to generate forms, it works fine with patched class file.
Cheers
M |
|
|
|
|
That's nice, but how to integrate it into the CVS with so many changes?
It would be better to have one patch per every feature. |
|
|
|
mmikrut@cyberone.com.au
|
|
2005-04-23 15:01
|
|
I will when I have a moment, which will probably be in a couple of weeks time.
I am under a lot of work pressure now :(
I was also thinking of replacing the file upload trigger with the code within the class itself, so no external triggers are requried for this to work.
Triggers should be left for users to do their own stuff.
Cheers
M |
|
|
|
mmikrut@cyberone.com.au
|
|
2005-04-23 20:08
|
|
Ok, I uploaded a 'file upload only' patch :)
Other changes (css fix, too many </tr></table>, sub forms) removed.
You will still need to integrate the javascript (mm_demo/scripts/fileupload.js) and file uplod trigger (mm_demo/triggers/uploader.php) from my demo |
|
|
|
plemieux
|
|
2005-05-12 21:20
|
|
|
With the actual patch (1.167+patch), is there a way to (at least) delete the record in the database. If we could also delete the file, it would be even better. |
|
|
|
plemieux
|
|
2005-05-13 00:54
|
|
There seems to be a problem in the trigger file in the part that deals with removing filepath for empty field.
I'm new to php, so my comment and code suggestion may not be correct.
I think array_splice is not used correctly.
I replaced:
foreach( $_FILES AS $key => $val ){
$b = 0;
if ( empty ( $_FILES[$key]['name'] ) ) {
array_splice($pathArray, $b,1);
}
$b++;
}
with:
$b = 0;
foreach( $_FILES AS $key => $val ){
if ( !empty ( $_FILES[$key]['name'] ) ) {
$pathArray2[] = $pathArray[$b];
}
$b++;
}
and change move_uploaded_file to use $pathArray2
There is probably a more elagant way to do it but that works for me. :)
edited on: 2005-05-13 00:55
edited on: 2005-05-13 00:56 |
|
|
|
|
Thanks to all for this feature.
I have a question, is possible work without javascript? maybe with only triggers?
My knowledge isn't enought, I get the filename in uploader trigger but how pass the filename from trigger to form or some variable for insert in database?
Sorry my bad english.
edited on: 2005-08-12 10:25 |
|
|
|
mattpaul
|
|
2006-06-13 00:17
|
|
Thanks for adding this functionality - the patch worked well for me. other users - remember to change the imagepath in the tbctattachments.php file (probably should be made into a define, kept in the config.inc)
I also added the ability to display u/l'd files as an img via setting the following options:
'IMG' => true,
'IMGheight' => 100,
'IMGwidth' => 100,
'URL' => 'files/contacts/$key.$value',
...
then just modify the displayURL() function in phpMyEdit.class.php to check if the 'IMG' option has been set, and then output as an <img src="$urllink"> accordingly...
cheers,
mattpaul |
|
|
|
|
I read this Bugnote and I thing than we complicate a little bit the solution, using triggers, normal enctype and multipart enctype,...
And finaly this feature is not in 5.6 phpMyEdit version.
Please could we add to phpMyEdit some simple to use multimedia components (not only images) :
. Files are stored on the serveur as separate files.
. only "Filename.ext" are stored in the database.
. Browse and Upload buttons activating js scripts to do the actions.
. A phpMyEdit.Upload.php script create file in the server
. housekeeping of obsoletes files on the server is not a phpMyEdit concern
. incomplete processus (file not uploaded) is not a phpMyEdit concern
. file adminstration should be done with ad-hoc housekeeping PHP script and/or tools like phpWebFileManager
Parameters proposal : (should be modified acording to development constraints)
$opts['fdd']['col_name']['select'] = 'I'; // Image and multImedIa
$opts['fdd']['col_name']['URL'] = 'http://path/to/images/$value'; // static url or
$opts['fdd']['col_name']['URL'] = 'http://path/to/images.php?x=32&y=24&img=$value'; // picture generated by script
$opts['fdd']['col_name']['path'] = './server/path/to/images/$value'; // upload path in the server
In ACP mode, we get a text field with 2 buttons [browse] and [upload] in the same <td> cell,
. browse allow to brose local computer and put selected local path/file in the field
. upload alllow to upload the selected file to the Server (acording to path)
. buttons activating js scripts to do the actions and a phpMyEdit.Upload.php script create file in the server
. file name (without path) is stored in the database
In VDLF mode, we get a generated multimedia field with folowing parameters :
$opts['fdd']['col_name']['display'] = 'image|link|icone'; // not the bolean general display array
. image generate a <IMG> field with parameters
$opts['fdd']['col_name']['IMGwidth'] = '640'; // define HLTL <img> attributes
$opts['fdd']['col_name']['IMGheight'] = '480'; // define HLTL <img> attributes
. link generate a <A> field linked to the image(or other document type) and $value as link text.
. icone generated a <A> linked to the image(or other document type) and an <img> with a picture depending to the the file extension
(example xxx.jpg display the jpg.gif icone, xxx.doc display the doc.gif icone, xxx.mp3 display the mp3.gif icone, ...)
Thanks to officialise (incorporating in the 5.6.n version and put the status of this bugnotes to "resolved")the patches discussed on this bugnote or implement a simple multimedia fiels as I propose. |
|
|
|
|
It seam than Fardeen Ghulam develop a solution to this Image upload.
http://fardeen.biz/index.php/tutoriel-administration-mysql-php-rapide-et-facile/
(sory it's in french ! )
Should we include this developement in an official phpMyEdit release ? |
|
|
|
|
|
Tutorial looks fine, however I have difficulties to understand the content, because I cannot speak French. I here someone from France to help me with that? |
|
|
|
|
-removed-
edited on: 2009-10-27 09:56 |
|
|
|
|
How can I use this Image uploading and viewing feature?
I use this phpMyEdit-5.7.tar.gz (Anyway this has a double "LIMIT" bug in the query generation (
-570. line: $ret .= ' LIMIT '.$parts['limit'];
+570. line: $ret .= ' '.$parts['limit'];
) ) |
|
|
|
pchanna1
|
|
2007-12-28 13:10
|
|
|
Did Fellz ever post his/her solution? |
|
|
|
pchanna1
|
|
2007-12-28 13:29
|
|
|
Did Fellz ever post his/her solution? |
|
|
|
thomas.wichmann
|
|
2008-10-30 11:03
|
|
I have added an updated version of the patch patch-mm-fileupload for the current version 5.7.1 for both classes phpMyEdit_mce_cal and phpMyEdit:
wichmann_20081028_phpMyEdit_patch.zip |
|
|
|
thomas.wichmann
|
|
2008-10-30 11:03
|
|
I have added an updated version of the patch patch-mm-fileupload for the current version 5.7.1 for both classes phpMyEdit_mce_cal and phpMyEdit:
wichmann_20081028_phpMyEdit_patch.zip |
|
|
|
thomas.wichmann
|
|
2008-10-30 11:07
|
|
|
I have added an updated version of the patch patch-mm-fileupload for the current version 5.7.1 for both classes phpMyEdit_mce_cal and phpMyEdit: |
|
|
|
daniel5420
|
|
2008-12-10 09:03
|
|
|
I used the patch file and got the file to upload. However, it is not storing the textual value into the DB for me to reference. What am I doing wrong? |
|
|
|
|
|
Hello Thomas, I have also used the patch but as daniel5420 the textual value is not wroten into the DB: can you send an example of your configuration to us? Thank you very much. |
|
|
|
|
|
Hello Thomas, I have also used the patch but as daniel5420 the textual value is not wroten into the DB: can you send an example of your configuration to us? Thank you very much. |
|
|
|
|
|
Hello Thomas, I have also used the patch but as daniel5420 the textual value is not wroten into the DB: can you send an example of your configuration to us? Thank you very much. |
|
|
|
|
|
Hi, to obtain the name of the textual value must be used the global var $_FILE as in the "uploader.php". Bye. |
|
|
|
Ryan Ward
|
|
2009-03-30 21:44
|
|
Thomas - your work to update the patches is excellent.
Are you able to most a patch for the latest CVS version phpMyEdit-mce-cal.class.php
phpMyEdit/extensions/phpMyEdit-mce-cal.class.php,v 1.10 2008-05-21 17:28:17 ajh
I've upgraded to use the latest TinyMCE version but it's not compatible with the file upload patch. I've tried editing it myself, but failing miserably at present..... |
|
|
|
|
|
I would like to apply the thomas.wichmann patch, but I have no idea of how to use the two text files downloaded. Rename .txt file to .php and upload to the phpMyEdit directory on the server? |
|
|
|
|
|
I would like to apply the thomas.wichmann patch, but I have no idea of how to use the two text files downloaded. Rename .txt file to .php and upload to the phpMyEdit directory on the server? |
|
|
|
|
I have used Thomas patch wichmann_20081028_phpMyEdit_patch.zip but the filename is not being written to the DB. Can anyone tell me where and what to change so it can write filename to DB. Thanks in advance.
I have added java script and upload triggers to the generated php page and also here is my column options.
$opts['fdd']['image'] = array(
'name' => 'Image',
'input' => 'F',
'imagepath' => '/srv/www/htdocs/images/',
'select' => 'T',
'maxlen' => 70,
'sort' => true
); |
|
|
|
|
I have used Thomas patch wichmann_20081028_phpMyEdit_patch.zip but the filename is not being written to the DB. Can anyone tell me where and what to change so it can write filename to DB. Thanks in advance.
I have added java script and upload triggers to the generated php page and also here is my column options.
$opts['fdd']['image'] = array(
'name' => 'Image',
'input' => 'F',
'imagepath' => '/srv/www/htdocs/images/',
'select' => 'T',
'maxlen' => 70,
'sort' => true
); |
|
|
|
|
There are two minor bugs in the mm_file_upload_demo.zip that, to best of my knowledge, subsequent patches do not address. The problems are in triggers/uploader.php:
Change the following line:
$fileN = str_replace( "\'", "", $fileN );
to:
$fileN = str_replace( "'", "", $fileN );
And the following code block:
//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++;
}
to:
//kill any paths from the array for image fields that may have been left blank - so paths correspond to images
$b = 0;
foreach( $_FILES AS $key => $val ) {
if ( empty ( $_FILES[$key]['name'] ) ) {
array_splice($pathArray, $b, 1);
} else {
$b++;
}
}
The first fix would correctly eliminate single quote from file names. The second fix would allow uploading multiple files on a single form. |
|
|
|
wolverine2005
|
|
2010-12-28 22:49
|
|
|
I kept getting an error saying the image could not upload. I have changed directory path and tried everything.Any help? |
|