[PHP] Re: uploading files... necessary Ajax?
T.Lensselink wrote: On Wed, 21 Nov 2007 08:38:18 -0600, Jay Blanchard [EMAIL PROTECTED] wrote: [snip] Seems to me Pere want's to do an upload without reloading the whole page. [/snip] The problem is that you cannot upload files using Ajax alone. But you can do it without a reload, requires an invisible IFRAME and a little technique. Search Google for several different articles on this. Indeed uploading with only Ajax is not possible. The already named iframe technique was the only thing i could think of. I was just curious if Jochem knew some other way of tackling this problem. I've not tried but I thought the point of returning a status code as Jochem mentioned would cause the browser to not need to download the content again? e.g. it gets a status code of e.g. 304 Not Changed and no data will the browser need to reload the page from it's cache or will it just keep the current page as it is. I would have thought this was a client-side implementation issue rather than anything else. Of course with these codes you can't inform someone that something has gone wrong, but I guess you only issue the codes on success. That said it will be a little odd exerpience for the user without some form of positive feedback. Just a click a small wait with mouse cursor whirring then it stops and that's it bit odd. Col -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: uploading files... necessary Ajax?
Colin Guthrie wrote: T.Lensselink wrote: On Wed, 21 Nov 2007 08:38:18 -0600, Jay Blanchard [EMAIL PROTECTED] wrote: [snip] Seems to me Pere want's to do an upload without reloading the whole page. [/snip] The problem is that you cannot upload files using Ajax alone. But you can do it without a reload, requires an invisible IFRAME and a little technique. Search Google for several different articles on this. Indeed uploading with only Ajax is not possible. The already named iframe technique was the only thing i could think of. I was just curious if Jochem knew some other way of tackling this problem. I've not tried but I thought the point of returning a status code as Jochem mentioned would cause the browser to not need to download the content again? e.g. it gets a status code of e.g. 304 Not Changed and no data will the browser need to reload the page from it's cache or will it just keep the current page as it is. I would have thought this was a client-side implementation issue rather than anything else. correct. you send a request to the server, which includes the file being uploaded - at the stage of sending a request there is nothing to reload, all the way through the upload the page just sits there. when the server completes handling the request it will send a status header and optionally some content. inb the case of return a 304 to the browser, your telling the browser to use whatever it's already displaying - actually I feel the 204 status is more appropriate. in both cases no content is returned, and no page is refreshed/reloaded/whatever :-) Of course with these codes you can't inform someone that something has gone wrong, but I guess you only issue the codes on success. That said it will be a little odd exerpience for the user without some form of positive feedback. Just a click a small wait with mouse cursor whirring then it stops and that's it bit odd. I agree. Col -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: uploading files... necessary Ajax?
Hi gang: So that I can get my head around this, are all of you saying there is no Ajax equivalent of: form action=index.php enctype=multipart/form-data method=post input type=hidden name=MAX_FILE_SIZE value=2048000 input name=userfile type=file input type=hidden name=stage value=1 input type=submit value=submit We can't in some way use the ajax post method to send the file in the background without a refresh (other than using iframe) is that correct? Or am I completely missing something here? Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: uploading files... necessary Ajax?
That's correct as far as I know... Ajax would require javascript had access to the data stream of the file you are trying to upload... and that would be a security issue for browsers (or was it because the multipart/form-data encoding? Don't kill me if I'm totally wrong). All in all, the only way to do a file upload I know of is with an iframe or with a SWF technique (which provides a bit more control on the progress of the upload). But any of those techniques will be transaparent to the end user if implemented well (meaning they will not know you are actually using an iframe or a SWF). Hope not to be far from thruth Rob (sorry, top posting, we've all read the rest of it :D) -Original Message- From: tedd [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 21, 2007 2:13 PM To: Jochem Maas; Colin Guthrie Cc: php-general@lists.php.net Subject: Re: [PHP] Re: uploading files... necessary Ajax? Hi gang: So that I can get my head around this, are all of you saying there is no Ajax equivalent of: form action=index.php enctype=multipart/form-data method=post input type=hidden name=MAX_FILE_SIZE value=2048000 input name=userfile type=file input type=hidden name=stage value=1 input type=submit value=submit We can't in some way use the ajax post method to send the file in the background without a refresh (other than using iframe) is that correct? Or am I completely missing something here? Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: uploading files... necessary Ajax?
[snip] That is correct. Without an IFRAME you cannot upload a file without a refresh. [/snip] Take Two. You could also open another window, but that kinda defeats the purpose. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: uploading files... necessary Ajax?
Jay Blanchard wrote: [snip] So that I can get my head around this, are all of you saying there is no Ajax equivalent of: form action=index.php enctype=multipart/form-data method=post input type=hidden name=MAX_FILE_SIZE value=2048000 input name=userfile type=file input type=hidden name=stage value=1 input type=submit value=submit We can't in some way use the ajax post method to send the file in the background without a refresh (other than using iframe) is that correct? Or am I completely missing something here? [/snip] That is correct. Without an IFRAME you cannot upload a file without a refresh. huh? if I post a file to a script that returns a 204 status and nothing else then the page should not change in the browser. of course as Colin pointed out this leaves much to be desired in terms of usability so for practical purposes you'll want to use an Iframe hack or upload widget built with java or flash. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: uploading files... necessary Ajax?
[snip] So that I can get my head around this, are all of you saying there is no Ajax equivalent of: form action=index.php enctype=multipart/form-data method=post input type=hidden name=MAX_FILE_SIZE value=2048000 input name=userfile type=file input type=hidden name=stage value=1 input type=submit value=submit We can't in some way use the ajax post method to send the file in the background without a refresh (other than using iframe) is that correct? Or am I completely missing something here? [/snip] That is correct. Without an IFRAME you cannot upload a file without a refresh. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: uploading files... necessary Ajax?
At 11:32 AM -0600 11/21/07, Jay Blanchard wrote: [snip] huh? if I post a file to a script that returns a 204 status and nothing else then the page should not change in the browser. [/snip] True, the missing piece is that the post cannot move the file up to the server. Ahhh, so that's it. My twitchy little brain was thinking if I can send arguments to the server via ajax, then why can't I send multipart/form-data? After all, data is data right? It might be too cpu intensive, but I can imagine js breaking down an image file in packets and then sending those to a server via post arguments to be assembled on the server. Is that not feasible, or am I blowing wind out my shorts again? Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: uploading files... necessary Ajax?
[snip] huh? if I post a file to a script that returns a 204 status and nothing else then the page should not change in the browser. [/snip] True, the missing piece is that the post cannot move the file up to the server. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: uploading files... necessary Ajax?
[snip] Ahhh, so that's it. My twitchy little brain was thinking if I can send arguments to the server via ajax, then why can't I send multipart/form-data? After all, data is data right? It might be too cpu intensive, but I can imagine js breaking down an image file in packets and then sending those to a server via post arguments to be assembled on the server. Is that not feasible, or am I blowing wind out my shorts again? [/snip] The wind does blow JS does not have permissions to do such file handling. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: uploading files... necessary Ajax?
tedd wrote: At 12:23 PM -0600 11/21/07, Jay Blanchard wrote: [snip] But, take a look at this: http://www.captain.at/ajax-file-upload.php They look like their blowing the same wind. [/snip] Yep, look at all of the gotchas. Well, I wasn't able to get it to work -- I couldn't find where to change the FF settings (Mac). type 'about:config' into the address bar :-) Cheers, tedd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: uploading files... necessary Ajax?
Jay Blanchard wrote: [snip] huh? if I post a file to a script that returns a 204 status and nothing else then the page should not change in the browser. [/snip] True, the missing piece is that the post cannot move the file up to the server. I was referring to a standard POST not using AJAX. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: uploading files... necessary Ajax?
At 12:23 PM -0600 11/21/07, Jay Blanchard wrote: [snip] But, take a look at this: http://www.captain.at/ajax-file-upload.php They look like their blowing the same wind. [/snip] Yep, look at all of the gotchas. Well, I wasn't able to get it to work -- I couldn't find where to change the FF settings (Mac). Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: uploading files... necessary Ajax?
At 11:49 AM -0600 11/21/07, Jay Blanchard wrote: [snip] Ahhh, so that's it. My twitchy little brain was thinking if I can send arguments to the server via ajax, then why can't I send multipart/form-data? After all, data is data right? It might be too cpu intensive, but I can imagine js breaking down an image file in packets and then sending those to a server via post arguments to be assembled on the server. Is that not feasible, or am I blowing wind out my shorts again? [/snip] The wind does blow JS does not have permissions to do such file handling. Yeah, the permission thing again. But, take a look at this: http://www.captain.at/ajax-file-upload.php They look like their blowing the same wind. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: uploading files... necessary Ajax?
[snip] But, take a look at this: http://www.captain.at/ajax-file-upload.php They look like their blowing the same wind. [/snip] Yep, look at all of the gotchas. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Re: uploading files... necessary Ajax?
-Original Message- From: Jay Blanchard [mailto:[EMAIL PROTECTED] Sent: Wednesday, November 21, 2007 3:24 PM To: tedd; Jochem Maas Cc: Colin Guthrie; php-general@lists.php.net Subject: RE: [PHP] Re: uploading files... necessary Ajax? [snip] But, take a look at this: http://www.captain.at/ajax-file-upload.php They look like their blowing the same wind. [/snip] Yep, look at all of the gotchas. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php So, I was not that wrong at all... So, one point more in favor of swfupload, despite being beta, it's more suitable than the about:config stuff. I will surely try swfupload in the next CMS I get involved with. Rob -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: uploading files... necessary Ajax?
At 8:03 PM +0100 11/21/07, Jochem Maas wrote: tedd wrote: Well, I wasn't able to get it to work -- I couldn't find where to change the FF settings (Mac). type 'about:config' into the address bar :-) I know I'll get a big argument from all of you about this, but sometimes I can be pretty dumb. :-) Thanks, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Uploading Files into MySQL
I am working on a script to upload files into MySQL db. The following script uploads to a file system how do I go about uploading the file into the DB? Where do I put the SQL statement in the code below? Let's see: script upload file mysql database Hmm, add php and you have Google php script upload file mysql database You can thank me later. *snap* -- Jared Farrish Intermediate Web Developer Denton, Tx Abraham Maslow: If the only tool you have is a hammer, you tend to see every problem as a nail. $$
Re: [PHP] Re: Uploading Files Should I use MySQL or Server for storage?
itoctopus wrote: I have tried both, and I tell you that I really felt that the filesystem is a more convenient way of doing it. I have to agree, filesystems were after all designed to store files. I reckon reading a file from disk is much quicker than reading from a database, maybe only fractionaly though. -- Regards, Clive. Real Time Travel Connections {No electrons were harmed in the creation, transmission or reading of this email. However, many were excited and some may well have enjoyed the experience.} -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Uploading Files Should I use MySQL or Server for storage?
On 5/22/07, clive [EMAIL PROTECTED] wrote: itoctopus wrote: I have tried both, and I tell you that I really felt that the filesystem is a more convenient way of doing it. I have to agree, filesystems were after all designed to store files. I reckon reading a file from disk is much quicker than reading from a database, maybe only fractionaly though. -- Regards, Clive. Real Time Travel Connections Ok, and what about Security etc? We only talk about speed here. Databases are username password protected. Files stored at the filesystem are unprotected. If you server files directly from the filesystem through Apache, without interaction of PHP you might end up with people uploading all kind of hacks. For example if they upload PHP files, and they get served directly, then the PHP code will probably be executed. Also, if you end up with a lot of files on one big disk (also for RAID 0), it would result in slow speeds for finding the actual data on the disk. Read operations are faster, but for small files, a database would be faster. This is probably not for your project, as you're files are little bit larger. [Please, don't ask for benchmarks of above statement.] Tijnema -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: Uploading Files Should I use MySQL or Server for storage?
On Tue, 2007-05-22 at 11:00 +0200, clive wrote: itoctopus wrote: I have tried both, and I tell you that I really felt that the filesystem is a more convenient way of doing it. I have to agree, filesystems were after all designed to store files. I reckon reading a file from disk is much quicker than reading from a database, maybe only fractionaly though. And databases were created to relate data. So if you're image is related to something, then it follows using your naive logic, that the image belongs in the database. It just so happens that database data usually resides on the filesystem, and thus your logical argument is still met. Thus, continuing to follow along this pendantic semantic path, it makes more sense that the image be in the database since more requirements are fulfilled. As I'm sure you can see, this logic has holes in it :) Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Uploading Files Should I use MySQL or Server for storage?
[EMAIL PROTECTED] wrote: I am in the process of adding a part to my website which would include pictures, pdf files, txt files, and excel files. The files sizes could be anywhere on average of 100k to 2mb. Do you think I should be uploading the files to a MySQL database or to my server? I have head that there are pros and cons to both, but have never really received a definitive answer that helps much. I appreciate all your opinions on the pros and cons of both. benc11, I store most of my data in both. when i do image processing i usually upload the image, store the original in the database, process the image into its subsequent sizes or resolutions and store them on the file system. If the images get lost on the file system or my application can not find them I have the original stored in the db for reprocessing. I store files other than images, PDF DOC etc... in the database and on the file system. i serve the document from the file system because regardless of the thread of conversation it is in my experience that 99% of the time it is faster to do so. if its not found i know i have a fall back in that it is also stored in the database so i serve that. Sure my method uses more storage space, but I sleep at night knowing I have added redundancy. Kind regards, Jonathan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Uploading Files Should I use MySQL or Server for storage?
Best of both worlds may be SQLite. ZEND has a nice article on the subject. [EMAIL PROTECTED] wrote: I am in the process of adding a part to my website which would include pictures, pdf files, txt files, and excel files. The files sizes could be anywhere on average of 100k to 2mb. Do you think I should be uploading the files to a MySQL database or to my server? I have head that there are pros and cons to both, but have never really received a definitive answer that helps much. I appreciate all your opinions on the pros and cons of both. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Uploading Files Should I use MySQL or Server for storage?
I have tried both, and I tell you that I really felt that the filesystem is a more convenient way of doing it. -- itoctopus - http://www.itoctopus.com [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] I am in the process of adding a part to my website which would include pictures, pdf files, txt files, and excel files. The files sizes could be anywhere on average of 100k to 2mb. Do you think I should be uploading the files to a MySQL database or to my server? I have head that there are pros and cons to both, but have never really received a definitive answer that helps much. I appreciate all your opinions on the pros and cons of both. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: uploading files
* Marc Serra [EMAIL PROTECTED]: Hi, i want to create a form to upload a file on a server. My problem is that i want to check the filesize before sending it because if the filesize is superior than 2 MB it failed and i don't want to wait for a long time for uploading a file that will fail. Can you please give me a solution to check the filesize. See: http://php.net/features.file-upload Basically, you need a MAX_FILE_SIZE hidden attribute in your form: input type=hidden name=MAX_FILE_SIZE value=200 / However, the manual goes on to say: The MAX_FILE_SIZE hidden field (measured in bytes) must precede the file input field, and its value is the maximum filesize accepted. This is an advisory to the browser, PHP also checks it. Fooling this setting on the browser side is quite easy, so never rely on files with a greater size being blocked by this feature. The PHP settings for maximum-size, however, cannot be fooled. This form element should always be used as it saves users the trouble of waiting for a big file being transferred only to find that it was too big and the transfer failed. So, adding the above input field is a good first step, but it's not foolproof; you may still get some too large files uploaded that PHP will reject after the fact. -- Matthew Weier O'Phinney | WEBSITES: Webmaster and IT Specialist | http://www.garden.org National Gardening Association| http://www.kidsgardening.com 802-863-5251 x156 | http://nationalgardenmonth.org mailto:[EMAIL PROTECTED] | http://vermontbotanical.org -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Uploading Files
My script now reads: ?php $uploadpath = /home/sites/site176/web/makeit; if($userfile) { move_uploaded_file ($_FILES ['userfile']['tmp_name'], $uploadpath/$userfile_name); echo $userfile_name; echo Successfully Added!br\n; //$username : contains the name of TMP file, $usrfile_name : it's the real name of file } ? form enctype=multipart/form-data action=?php echo $PHP_SELF ? method=post name=upload File to Upload: input type=file name=userfileBR input type=submit value=Upload /form I now get: Warning: Unable to create '/home/sites/site176/web/makeit/Ski club logo high resolution.jpg': Permission denied in /home/sites/site176/web/admin/renew_snowreport.php on line 102 I am not sure how or where to change the permissions so I can upload into this directory? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: uploading files
My apologies, here is the code! //copy image to server if ($image != none) { if (copy ($image, $dir.$image_name)){ echo pFile upload successful!/p; } else { echo pFile upload unsuccessful!/p; } //new name of image $new_name = $property_id-$category_id-$sub_category_id.jpg; //rename the file rename($dir.$image_name, $dir.$new_name); } Shaun Thornburgh [EMAIL PROTECTED] wrote in message news:20021101205003.11053.qmail;pb1.pair.com... I am attempting to upload image files to the server from a users browser using the following code, however, the images seem to get corrupted, they look completely different and the file sizes are generally smaller, also it sometimes says file upload unsuccessful, even when it does upload the file? Any ideas? Thank you -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Fw: [PHP] Re: uploading files
Confirm that you're using the proper header information in your HTML form tag.. form action=upload.php method=POST enctype=multipart/form-data -Kevin - Original Message - From: Shaun Thornburgh [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, November 01, 2002 1:51 PM Subject: [PHP] Re: uploading files My apologies, here is the code! //copy image to server if ($image != none) { if (copy ($image, $dir.$image_name)){ echo pFile upload successful!/p; } else { echo pFile upload unsuccessful!/p; } //new name of image $new_name = $property_id-$category_id-$sub_category_id.jpg; //rename the file rename($dir.$image_name, $dir.$new_name); } Shaun Thornburgh [EMAIL PROTECTED] wrote in message news:20021101205003.11053.qmail;pb1.pair.com... I am attempting to upload image files to the server from a users browser using the following code, however, the images seem to get corrupted, they look completely different and the file sizes are generally smaller, also it sometimes says file upload unsuccessful, even when it does upload the file? Any ideas? Thank you -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: uploading files
Thats all fine Here is my form header form enctype=\multipart/form-data\ name=\Edit_Category_Form\ method=\post\ action=\edit_images_form.php?property_id=$property_idcategory_id=$category _idsub_category_id=$sub_category_idsub_category_title=$sub_category_title sub_category_description=$sub_category_description\ Kevin Stone [EMAIL PROTECTED] wrote in message news:020201c281ec$04515820$6601a8c0;kevin... Confirm that you're using the proper header information in your HTML form tag.. form action=upload.php method=POST enctype=multipart/form-data -Kevin - Original Message - From: Shaun Thornburgh [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, November 01, 2002 1:51 PM Subject: [PHP] Re: uploading files My apologies, here is the code! //copy image to server if ($image != none) { if (copy ($image, $dir.$image_name)){ echo pFile upload successful!/p; } else { echo pFile upload unsuccessful!/p; } //new name of image $new_name = $property_id-$category_id-$sub_category_id.jpg; //rename the file rename($dir.$image_name, $dir.$new_name); } Shaun Thornburgh [EMAIL PROTECTED] wrote in message news:20021101205003.11053.qmail;pb1.pair.com... I am attempting to upload image files to the server from a users browser using the following code, however, the images seem to get corrupted, they look completely different and the file sizes are generally smaller, also it sometimes says file upload unsuccessful, even when it does upload the file? Any ideas? Thank you -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: uploading files
How are you handling the transfer of files between its temporary area and where it's going to be stored? If you're copying instead of moving, I would imagine the file in the temp directory would still be present. -Jason Donahue Ben wrote: I am uploading a gif file using is_upload_file($filename) function. I save the file with a file name img1.gif. It seems to work fine. But when I delete the file img1.gif then upload a different gif file and save it as img1.gif, it displays the first image i uploaded not the most recent one, why is this? Is there a way to get around it? Ben __ Do you Yahoo!? Faith Hill - Exclusive Performances, Videos More http://faith.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: uploading files
Possibly. But temp files created during execution should be destroyed when the script exists. So either copying or moving shouldn't make any difference. Besides that I think the difference is strictly semantic. Another possibility is that this is a browser cache issue. -Kevin - Original Message - From: Jason Young [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Monday, October 07, 2002 11:24 AM Subject: [PHP] Re: uploading files How are you handling the transfer of files between its temporary area and where it's going to be stored? If you're copying instead of moving, I would imagine the file in the temp directory would still be present. -Jason Donahue Ben wrote: I am uploading a gif file using is_upload_file($filename) function. I save the file with a file name img1.gif. It seems to work fine. But when I delete the file img1.gif then upload a different gif file and save it as img1.gif, it displays the first image i uploaded not the most recent one, why is this? Is there a way to get around it? Ben __ Do you Yahoo!? Faith Hill - Exclusive Performances, Videos More http://faith.yahoo.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Uploading Files
Jason [EMAIL PROTECTED] disgorged: : I would like to be able to upload files from the client computer to the : server via a form. I know how to build the form, but am not sure of the : best way to process this. I know there are certain ftp functions that can : do this, which I'm not sure how to use. Are there any others? http://www.php.net/manual/en/features.file-upload.php More specifically, move_uploaded_file() and is_uploaded_file() HTH.. Take care.. peace.. eriol -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Uploading Files
Okay, I checked out the link listed below, and tried using what is given there, but I get the following error: Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in d:\www_root\locutus\phpman\admin\test.php on line 16 Here's the code that I am using: form enctype=multipart/form-data action=test.php method=post input type=hidden name=MAX_FILE_SIZE value=10 Send this file: input name=userfile type=file input type=submit value=Send File /form ?php move_uploaded_file($_FILES['userfile']['tmp_name'], ../images/$_FILES['userfile']['name']); ? I am able to get rid of this error, but changing the line to: move_uploaded_file($_FILES['userfile']['tmp_name'], ../images/$_FILES[userfile][name]); However, the file is then uploaded as Array[name] How do I get past this? Jason Williard Eriol [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Jason [EMAIL PROTECTED] disgorged: : I would like to be able to upload files from the client computer to the : server via a form. I know how to build the form, but am not sure of the : best way to process this. I know there are certain ftp functions that can : do this, which I'm not sure how to use. Are there any others? http://www.php.net/manual/en/features.file-upload.php More specifically, move_uploaded_file() and is_uploaded_file() HTH.. Take care.. peace.. eriol -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Uploading Files
Jason [EMAIL PROTECTED] disgorged: : ?php : move_uploaded_file($_FILES['userfile']['tmp_name'], : ../images/$_FILES['userfile']['name']); : ? : : I am able to get rid of this error, but changing the line to: : move_uploaded_file($_FILES['userfile']['tmp_name'], : ../images/$_FILES[userfile][name]); : : However, the file is then uploaded as Array[name] : : How do I get past this? I'm not 100% sure this will work, but try this: ?php $savetopath = /path/to/your/upload/area . $userfile; mode_uploaded_file($_FILES['userfile']['tmp_name'], $savetopath); ? If you're using $_FILES, I assume you have Register_Globals = on? If not, use $HTTP_POST_FILES instead.. From 4.2.0 on register globals is off in the php.ini by default.. Also, you might try hotscripts.com for file upload scripts that allow one or multiple files at a time.. There may be a script there that's already created that'll serve your purpose.. http://www.hotscripts.com/PHP/Scripts_and_Programs/File_Manipulation/Upload_Sy stems/ HTH.. Take care.. peace.. eriol -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: uploading files problem
put dubble quotes inside your html. I think this is in the spec, as soon as it is no numeric format: input type=file name=file size=30 Cheers, Andy Claudio Fedel [EMAIL PROTECTED] schrieb im Newsbeitrag [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... hi there, I'm trying to upload a file using php on an apache server running on linux. The code of the form I'm using is as follow: form enctype=\multipart/form-data\ method=POST action=$PHP_SELF?action=doupload pFile to upload:br input type=file name=file size=30 input type=text name=zio size=30 pbutton name=submit type=submit Upload /button /form when I press the submit button after selecting the file, nothing happens. I tried to print the filename passed by the form but it is empty. If I run the same page on my win2k server, everything works fine. It seems as that the form doesn't pass post variables. I also tried to delete the enctype parameter and in this case the variables are printed on screen. Is there any particular setting on linux for this page to work? thanks -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Uploading Files through PHP
maybe your code is inside a function. If this is the case set the var to global. Andy Georgie Casey [EMAIL PROTECTED] schrieb im Newsbeitrag [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... I'm trying to let users upload word files through a PHP form but its not working! The script keeps telling me that the file path doesn't exist. HERE'S THE CODE I USE IN THE FORM PAGE: FORM ENCTYPE=multipart/form-data ACTION=freelancers/uploaded_word.php METHOD=POST INPUT TYPE=hidden name=MAX_FILE_SIZE value=1000 p align=center input type=submit value=Upload name=submit input type=file name=wordcv size=30 /p /form is the code on the form page, when i submit i'm told the $wordcv is a null. WHY?? -- Regards, Georgie Casey [EMAIL PROTECTED] *** http://www.filmfind.tv Ireland's Online Film Production Directory *** -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: uploading files | how to avoid submitting twice?
Jim Winstead wrote: Andy [EMAIL PROTECTED] wrote: Is there a way to redirect imediatelly to a waiting page? I tryed to redirect, but somehow the server is first uploading the file before something else happens. unfortunately, no. one thing you can do is use javascript to pop up a small window in your form's onsubmit method that tells the user to hang on, and then close that window in the next page's onload method. it isn't easy to do a real progress meter, but even this little bit should help tremendously. you may also want to check the md5 sum of the file contents against previous uploads to detect duplicates. jim I've never tried it, but it may also be possible to disable the submit button once it has been pressed once to stop the second upload e.g. HTML HEAD SCRIPT LANGUAGE=javascript function submitonce() { if (document.form.submitted.value == No) { document.form.submitted.value == Yes; return true; } else { alert(Please wait...); return false; } } /SCRIPT /HEAD BODY FORM OnSubmit=return submitonce(); INPUT TYPE=HIDDEN NAME=submitted VALUE=No INPUT TYPE=FILE NAME=uploadfile INPUT TYPE=SUBMIT OnClick=return submitonce(); /FORM /BODY /HTML N.B. I've set the form's OnSubmit and the submit button's onClick, only because I'm not sure which will work best. I'd expect this to work with a normal form submit but maybe file upload is funny... George -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: uploading files | how to avoid submitting twice?
Andy [EMAIL PROTECTED] wrote: Is there a way to redirect imediatelly to a waiting page? I tryed to redirect, but somehow the server is first uploading the file before something else happens. unfortunately, no. one thing you can do is use javascript to pop up a small window in your form's onsubmit method that tells the user to hang on, and then close that window in the next page's onload method. it isn't easy to do a real progress meter, but even this little bit should help tremendously. you may also want to check the md5 sum of the file contents against previous uploads to detect duplicates. jim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Uploading Files with PHP
Hi Jim, here's how I do it. I test for the file size on the processing page as well, if it's too large I redraw out the upload form. //test for file extension type if needed //determine file size -- if too big ( greater 50kb) then redirect $siz = filesize($userfile); if ($siz = 51200){ //redraw upload form print font face='verdana' size='2' class='text_size_9'The photo you attempted to upload was too large in file size. Please ensure that the file size does not exceed 50kb./font; print form method='POST' action='photoupload.php' enctype='multipart/form-data'input type='hidden' name='MAX_FILE_SIZE' value='51200' input type='file' name='userfile' size='15' style='font-family: Verdana; font-size: 8pt;'input type='submit' name='submit' value='Upload' style='font-family: Verdana; font-size: 8pt;'; print /form; } elseif ($siz 51200) { $timestamp = time(); $userfile_name = $timestamp.$userfile_name ; // copy the file being posted if(copy($userfile, /dir/dir/pics/. $userfile_name)){ print font face='verdana' size='2' class='text_size_9'Your photo has been uploaded and is viewable in the photo gallery./fontbrbr ; } else { print font face='verdana' size='2' class='text_size_9'A problem was encountered during your photo upload./fontbr; } $patharola = pics/. $userfile_name; //connect to db $connectionToDBid = odbc_connect(dgsff, sdgsdfg, sdfgsdfg); //create query statement $sqlr = INSERT INTO PHOTO (golferid, photo, caption, datesubmitted) VALUES ('$sesgolferid' , '$patharola', '$caption', '$todaysdate' ); //execute the sql statement (query) on the connection made $resultset = odbc_do($connectionToDBid, $sqlr); blah blah blah ... Hope this helps you out, Joe :) Jim Koutoumis [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Joe, Do you know when the file size is checked ?? I think it only gets checked after the form is posted and file uploading is finished ?? I don't know how it's possible to catch things before user uploads - now that would be neat :-) Jim. Lerp [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hi there :) Did you set a max file size in your upload form? See my form below, notice the 'MAX_FILE_SIZE' value='102400' part within hidden field. This should appear before the rest of the form. You can adjust this value as you wish. form action='resumeupload.php' method='post' enctype='multipart/form-data' input type='hidden' name='MAX_FILE_SIZE' value='102400' font color='#663399' face='verdana' size=2bUpload Resume:/b/font input type='file' name='userfile' style='background-color: #FF; font-family: verdana; font-weight: bold; color: #FF; font-size: 9pt;' input type='submit' value='Upload!!!' style='background-color: #FF; font-family: verdana; font-weight: bold; color: #FF; font-size: 9pt;' name=submit /form Hope this helps, Joe :) Chuck Pup Payne [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hi, I am trying to set a small script that would let my clients upload file with a Explorer or Netscape, but the problem is it would let me upload any file that is great than a 1MB. We get an error that the file none could not be read. I have set the upload_tmp_dir=/tempupload is has been chmod to 777, php.ini as been set to 20MB, I know that is a lot but we are engingeering company that work with CADD files. Any clues where to look? The PHP 4 Bible from IDG states that we have to under HTTP uploads, but nothing else. Is there some where on the net that explains better what I have to set up, turn on, or haven't done? Thanks, Chuck -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Uploading Files with PHP
Ammendment: Actually, I was just looking at one of my photoupload processes and I actually removed the MAX_FILE out of the upload form and only tested the file size on the processing page like in the previous message. Cheers, Joe :) Lerp [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hi Jim, here's how I do it. I test for the file size on the processing page as well, if it's too large I redraw out the upload form. file://test for file extension type if needed file://determine file size -- if too big ( greater 50kb) then redirect $siz = filesize($userfile); if ($siz = 51200){ file://redraw upload form print font face='verdana' size='2' class='text_size_9'The photo you attempted to upload was too large in file size. Please ensure that the file size does not exceed 50kb./font; print form method='POST' action='photoupload.php' enctype='multipart/form-data'input type='hidden' name='MAX_FILE_SIZE' value='51200' input type='file' name='userfile' size='15' style='font-family: Verdana; font-size: 8pt;'input type='submit' name='submit' value='Upload' style='font-family: Verdana; font-size: 8pt;'; print /form; } elseif ($siz 51200) { $timestamp = time(); $userfile_name = $timestamp.$userfile_name ; // copy the file being posted if(copy($userfile, /dir/dir/pics/. $userfile_name)){ print font face='verdana' size='2' class='text_size_9'Your photo has been uploaded and is viewable in the photo gallery./fontbrbr ; } else { print font face='verdana' size='2' class='text_size_9'A problem was encountered during your photo upload./fontbr; } $patharola = pics/. $userfile_name; file://connect to db $connectionToDBid = odbc_connect(dgsff, sdgsdfg, sdfgsdfg); file://create query statement $sqlr = INSERT INTO PHOTO (golferid, photo, caption, datesubmitted) VALUES ('$sesgolferid' , '$patharola', '$caption', '$todaysdate' ); file://execute the sql statement (query) on the connection made $resultset = odbc_do($connectionToDBid, $sqlr); blah blah blah ... Hope this helps you out, Joe :) Jim Koutoumis [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Joe, Do you know when the file size is checked ?? I think it only gets checked after the form is posted and file uploading is finished ?? I don't know how it's possible to catch things before user uploads - now that would be neat :-) Jim. Lerp [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hi there :) Did you set a max file size in your upload form? See my form below, notice the 'MAX_FILE_SIZE' value='102400' part within hidden field. This should appear before the rest of the form. You can adjust this value as you wish. form action='resumeupload.php' method='post' enctype='multipart/form-data' input type='hidden' name='MAX_FILE_SIZE' value='102400' font color='#663399' face='verdana' size=2bUpload Resume:/b/font input type='file' name='userfile' style='background-color: #FF; font-family: verdana; font-weight: bold; color: #FF; font-size: 9pt;' input type='submit' value='Upload!!!' style='background-color: #FF; font-family: verdana; font-weight: bold; color: #FF; font-size: 9pt;' name=submit /form Hope this helps, Joe :) Chuck Pup Payne [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hi, I am trying to set a small script that would let my clients upload file with a Explorer or Netscape, but the problem is it would let me upload any file that is great than a 1MB. We get an error that the file none could not be read. I have set the upload_tmp_dir=/tempupload is has been chmod to 777, php.ini as been set to 20MB, I know that is a lot but we are engingeering company that work with CADD files. Any clues where to look? The PHP 4 Bible from IDG states that we have to under HTTP uploads, but nothing else. Is there some where on the net that explains better what I have to set up, turn on, or haven't done? Thanks, Chuck -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Re: Uploading Files with PHP
Joe, Do you know when the file size is checked ?? I think it only gets checked after the form is posted and file uploading is finished ?? I don't know how it's possible to catch things before user uploads - now that would be neat :-) Jim. Lerp [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hi there :) Did you set a max file size in your upload form? See my form below, notice the 'MAX_FILE_SIZE' value='102400' part within hidden field. This should appear before the rest of the form. You can adjust this value as you wish. form action='resumeupload.php' method='post' enctype='multipart/form-data' input type='hidden' name='MAX_FILE_SIZE' value='102400' font color='#663399' face='verdana' size=2bUpload Resume:/b/font input type='file' name='userfile' style='background-color: #FF; font-family: verdana; font-weight: bold; color: #FF; font-size: 9pt;' input type='submit' value='Upload!!!' style='background-color: #FF; font-family: verdana; font-weight: bold; color: #FF; font-size: 9pt;' name=submit /form Hope this helps, Joe :) Chuck Pup Payne [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... Hi, I am trying to set a small script that would let my clients upload file with a Explorer or Netscape, but the problem is it would let me upload any file that is great than a 1MB. We get an error that the file none could not be read. I have set the upload_tmp_dir=/tempupload is has been chmod to 777, php.ini as been set to 20MB, I know that is a lot but we are engingeering company that work with CADD files. Any clues where to look? The PHP 4 Bible from IDG states that we have to under HTTP uploads, but nothing else. Is there some where on the net that explains better what I have to set up, turn on, or haven't done? Thanks, Chuck -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php