News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

attachment lost in preview

Started by Anguz, January 21, 2004, 10:50:25 PM

Previous topic - Next topic

Anguz

if you browse for a file to attach and preview the message, the attachment fields are empty and you have to browse for the file again
Cristián Lávaque http://cristianlavaque.com

Curbow 5

i'm not sure if it's possible to fix that... because of security reasons, you can't give a <input type=file> a value...

i maybe wrong though!

Curbow 5

i've thought about....
you can't add a value to the upload field in the preview screen, but you could of course upload the attachments on preview and then add a feature to 'detach' them again in case of a mistake.

move.to/feature_requests?

Peter Duggan

Quote from: Anguz on January 21, 2004, 10:50:25 PM
if you browse for a file to attach and preview the message, the attachment fields are empty and you have to browse for the file again

This has always been the case with YaBB SE as well, but I don't think the reasons have changed!

Anguz

I didn't know that, since I never used attachments in YaBB SE... do you remember what the reasons are? or have a link to the thread that mentions them? thanks :)
Cristián Lávaque http://cristianlavaque.com

Peter Duggan

Not offhand, but I think Curbow is close... IOW, you can't attach an attachment twice?

Peter Duggan


Curbow 5

Quote from: Anguz on January 22, 2004, 07:02:21 PM
I didn't know that, since I never used attachments in YaBB SE... do you remember what the reasons are?

it's a security issue. if you could enter a default value for a file field, i could gain access to files on your computer through auto submitting forms in hidden frames etc.

and that would be a BAD thing! ;)

Anguz

thanks you for your help... I checked on the file type for the input tag, I thought one could use the value attribute, but it's not possible

Curbow, I hadn't thought about it, but that's true

the only solution I can come up with for this right now, is have a temp folder inside the attachments one, where the files could be stored for previews and moved/deleted from it when posting
Cristián Lávaque http://cristianlavaque.com

SparkieGeek

#9
Could you not use JavaScript in an onload() to write to the attachment field? sorry that was a stupid idea

Curbow 5

#10
@Anguz
i was thinking along the lines of just uploading the files the normal way for preview, with an option to remove (i like the word detach :)) them again. that way smf doesn't have to go through the hassle of moving the files from /temp to /attachments etc.

most people wan't make a mistake in which file to upload anyway, so there's no real need for  a /temp

@Sparkiegeek
i don't think so, security's pretty right, the only thing i came up with that's even close was a 'fake' file filed (a text field and a submit button) where onclicking the button, you'd get send to a hidden file field of which the value was then transferred to the textfield..... it was just cosmetic and it wasn't even crossbrowser compatible.....  >:( :'(

Anguz

Quote from: SparkieGeek on January 22, 2004, 07:40:26 PM
Could you not use JavaScript in an onload() to write to the attachment field?
I don't know JS to answer that :P

but I like the idea of just uploading normally better,  because it'd let you see the attachments in the preview too :)
Cristián Lávaque http://cristianlavaque.com

SparkieGeek

Yeah like I said in my edit, it was a stupid idea. The security model can't be that flawed, if you could do that and were feeling malicious then you'd be able to hide the field and have JS upload a file of your choice on any form submission <-- bad, very bad

Curbow 5

#13
for your amusement, IE only i think:


<form name="uploadform" method="post" action="" enctype="multipart/form-data">
  <input name="filename" type="text" value="" size="32">
  <input name="browse" type="button" onClick="document.uploadform.realfile.click(); document.uploadform.filename.value = document.uploadform.realfile.value;" value="Browse...">
  <input name="submit" type="submit" value="Upload" />
  <input name="realfile" type="file" style="display:none;" size="0">
</form>

[Unknown]

What happens if you click away, though? (and don't post after all.)  That's why it currently doesn't just upload.

Try it now.  It warns you.. (Simple Machines theme only.)

-[Unknown]

Anguz

#15
the warning is nice, at least it doesn't come as a bad surprise later lol :P

about the person going away, then the temp folder might work... if the file there has more than xx minutes, it gets deleted... each time a file gets attached, the function could check the files in the temp folder and detach the old ones that weren't moved out of there to their final location

or

in the attachments table, there could be a column to mark a temp attachment when uploaded for a preview and unmark it when the message gets posted with it... next time an attachment is done, check the table for the marked ones and removed those that are too old

I like the latter better :)
Cristián Lávaque http://cristianlavaque.com

Curbow 5

[Unknown] has a point there, but would that happen often? The very few times I click away, don't usually involve previewing my post. I like the warning by the way, but the preferable situation would still be uploading the attachments upon preview.

well, at least that would be my preferable situation :D

Advertisement: