14

I posted a question and a couple of respondents asked for the source code. I could only post portions of the code.

If attachments were allowed I could have uploaded a .zip file with the whole application. Will this be a feature in SO?

2
  • 2
    Can the close voters please clarify why this question is no longer reproducible? Commented Nov 11, 2023 at 2:59
  • 1
    @Sonic herd behavior, which is too common even here, sadly. (I mean only the one who cast the first vote can answer, and we don't know who that is.) For now it's out of the close queue though. Commented Nov 11, 2023 at 9:09

14 Answers 14

37

I'm strongly against such a feature. StackOverflow is meant to be a knowledge exchange platform, where we try to build, say, the Wikipedia of programming questions, not a place for troubleshooting "hey, dig through my source code. fix the problem for me" issues for free.

Currently, if you look at the answers in Stack Overflow, many of them are much longer than "change that line to something else" type of answer. Many good answers here really try to explain the reason that caused the problem and many alternative suggestions. They are more like blog entries than classic answers found in forums. This is what makes Stack Overflow a unique Web site. Those answers can be useful for a lot of people, not just the OP.

As a consequence, I believe any feature that encourages asking arbitrarily long questions and make the OPs think less before asking is completely against the spirit of Stack Overflow. It would no longer be a knowledge exchange platform but place to troubleshoot specific problems, which in my opinion, is no fun at all.

4
  • 1
    the problem in your argument is you have issues with giving answers "for free"...right there, first paragraph.
    – dde
    Commented Jul 13, 2009 at 12:41
  • 4
    @dde: Don't get me wrong. I don't have any problems with sharing what I know and helping people in general. I think my SO profile pretty much proves this point. The thing I want to point out is that SO is not a place for people to come and have their job done by others. It's a place they should come primarily to share what they know and learn stuff they need to get their job done on their own. Uploading a ZIP file will essentially make SO like some freelance programming Websites sans the money (BTW, I won't be participating in them anyway, so the issue is not being free).
    – mmx
    Commented Jul 13, 2009 at 14:31
  • Whikipedia hosts some images, sounds and (I don't know if already does) video. We could use some image uploading goodies, for the ocasional UML graph.
    – perbert
    Commented Jul 28, 2009 at 16:40
  • Greeeeeeeaaaat answer! (And the right one in my opinion)
    – bobobobo
    Commented Nov 27, 2011 at 14:02
32

There are lots of free file hosts you can use -- it puts us in a difficult position to be hosting arbitrary files for user.

7
  • 1
    yes, this is a nice solution...upload there, put link here.
    – dde
    Commented Jul 13, 2009 at 12:39
  • 13
    If there were an API to those solutions, would SO ever implement it?
    – RSolberg
    Commented Jul 13, 2009 at 17:53
  • @Chester Yes, a ton of them have API's
    – bobobobo
    Commented Nov 27, 2011 at 14:01
  • 1
    If only people did this. I get that there would be problems hosting attachments, and if you don't want to dig through piles of code then don't -- down vote and move on. But for questions like this: stackoverflow.com/questions/15796659/… it would be far easier to download a project then create one, create each page, each control, gather the hosted copy of the local jquery version, cut and paste all the code, etc -- before even hitting F5.
    – user141064
    Commented Apr 3, 2013 at 20:01
  • 9
    The problem with this is what happens if some of those services close? All related questions with linked files will no longer be valid!! For example I was trying to add a sample docx file as an example of where the library was failing in the conversion (but the same could be true for image files). In any case, if the free hosting solution closes the question is now useless. You can't assume these services will stay up, especially if you want to keep the integrity, and hence value, of the questions over the longer term. Commented Dec 7, 2013 at 3:30
  • Dead link to smashingapps
    – Jan Doggen
    Commented Aug 15 at 6:06
  • @JanDoggen yeah, we should just edit those out, and if it leaves the answer blank or unusable, flag for moderator attention so it can be deleted. (We should assume users who aren't active a lot will not see comments) Commented Sep 5 at 9:59
13

SO allows a substantial amount of code to be posted. In all honesty, if you're finding the limit to be too little, you're probably not getting close enough to your problem before posting your question.

Many people, not accusing you, ask questions like "What's wrong with this?" and then plaster 100 lines of code into their browser (many times un-tabbed). Try not to be that person. Instead, use your error-reporting to determine what problematic section should be copied. That, or ask a more general question about your issue and extract a solution from the answers.

1
  • I see your point. Anyway, I managed to obtain an answer posting a few lines. I just though right at that moment it could have been very easy to upload what respondents were asking for. BTW, out of curiosity, how much amount of code is allowed?
    – dde
    Commented Jul 13, 2009 at 12:46
11

I think if you're posting a zip file of code for a question you're posting far too much.
Questions should be limited to specific problems or functions in your application so that the error can be readily seen and fixed by other members. I know I definitely wouldn't go digging through multiple files of code to try and solve an issue, but that's just me.

2
  • 1
    @Ian - While you may choose to not look over the sourcecode, that doesn't imply that another person wouldn't. It only takes one person to answer a tough question.
    – RSolberg
    Commented Jul 13, 2009 at 17:53
  • 1
    No Ian, it's not just you...
    – awe
    Commented Mar 21, 2012 at 10:44
7

When questions exhibit more than a dozen lines of code, I switch to another one. Digging the code for finding bugs is my real life job, and I am good at it because I have spent time for learning the context. Getting into that kind of learning curve is not something I expect from Stackoverflow.

As a potential answerer, I expect from Stackoverflow that the OP has already isolated his bug and is able to present its essence to the community.

As a potential asker, I expect from Stackoverflow that the essence of the problem I am struggling against has already been exposed and solved. This will never be the case if every problem is flooded with specific context.

6

I'm actually a bit surprised by the amount of negative emotions towards this in general... As Mehrdad pointed out, Stack Overflow is a great knowledge exchange platform. I completely agree. It is an excellent knowledge exchange platform. But why must we limit knowledge transfer to text?

The ability to upload supporting docs/code/images/etcetera to questions and answers is definitely a limitation of the overall SO experience. As Jonathan pointed out, questions that are along the lines of "hey whats wrong with these 200 lines of code" are going to be frowned upon. These questions will be met by down-votes and folks asking what the specific issue is. If someone were to post a project in a zip file and say "whats wrong with my project, it doesn't work"), it'll be met by huge resentment with downvotes, negative comments, etc.

So what do we lose by folks posting some zip files with project code in them? Do we stand to be negatively affected more by that or will our overall experience be improved? I certainly don't think it would be more negative and having this feature would only help some folks and make answers a bit more robust.

4
  • 5
    My take on this: 1) probably harms searchability. 2) discourages filtering the question down to an specific point and as a result, adds clutter, reduces the "being useful for many people", Wikipedia aspect to SO, and increases troubleshoot my very specific problem aspect which has long existed in traditional forums. 3) creates more ten questions in one posts. Uploading images and docs can be helpful but considering the free hosting services out there, copyright issues and the complexity it introduces, I don't think SO should directly support that.
    – mmx
    Commented Jul 13, 2009 at 20:09
  • @Mehrdad - not one of your points has an ounce of validity. How does adding files harm searchability? Searches can remain text based. If people don't ask questions properly, they'll be dinged and the behavior will not be rewarded. As the licensing and usage is already fairly well known, I don't think it adds anymore complexity as the same CC-WIKI rules can be applied to files.
    – RSolberg
    Commented Jul 13, 2009 at 20:19
  • 1
    @RSolberg: I can think of questions that will show up: "hey, my code won't compile. blah blah blah." with a ZIP file attached (which is not very searchable). Sure, it'll be downvoted, but this kind of behavior is likely to increase. Regarding copyright and objectionable content, well, I can already see people copying decompiled .NET framework source code from Reflector. There's not a solid measure to prevent uploading content that you don't have the rights for.
    – mmx
    Commented Jul 13, 2009 at 20:44
  • Nor should be. If someone files a complain, the offending post could be deleted if appropiate.
    – perbert
    Commented Jul 28, 2009 at 16:43
3

I'd like to approach this from another angle.

I spend a lot of time on the Electronics Stackexchange site, and many questions and/or answers there have links to component datasheets on external sites.

Now, I thought that the general policy was that questions and answers shouldn't rely on external sites if at all possible, so that if the external site went down / went through a restructuring, the question or answer was still complete and valid - hence the enforced use of imgur to host images.

Now, being able to attach the datasheet to the answer instead of referring to an external site must surely be a bonus to the longevity of the content in general.

I agree that uploading whole projects, or big code files is a no-no as this doesn't add any value to the content, but being able to attach files with information in to which the answer refers instead of relying on the data still being on an external site 6 months down the line has to be a big yes point.

Maybe it should only be allowed for answers, and not questions, and maybe for people with more than a certain threshold of reputation.

1
  • your answer makes a lot of sense to me. Indeed for answers and not questions, would be my suggestion
    – nawfal
    Commented Dec 23, 2011 at 9:35
2

I understant there are 10's of good reasons against uploading code files, however: what if it's the answers that require some uploads?

I had the perfect code for a utility function that did exactelly what the OP was asking for. Code was 200+ lines, and would probably benefited a lot of people trying strugling with the same formatting problems.

Then you could just answer:

Well, this is the function that I use to format a DataSet into an XML-compliant Office Excel 2007 document: codegoeshere.cs

I would love to be able to upload small 10-15kb human-readable text files.

1

Here's a (naive and dumb) SEDE query counting instances of the domain of the first URL used in any post containing a URL within a Stack Exchange, and having instance counts >= 10.

SELECT
  SUBSTRING(
    P.Body COLLATE Latin1_General_BIN,
    CHARINDEX('<a href=', P.Body COLLATE Latin1_General_BIN)+9,
    CHARINDEX(
      '/',
      P.Body COLLATE Latin1_General_BIN,
      CHARINDEX('<a href=', P.Body COLLATE Latin1_General_BIN)+9+8
    )-(CHARINDEX('<a href=', P.Body COLLATE Latin1_General_BIN)+9)
  ) AS Url,
  COUNT(*) AS [Count]
FROM Posts P
WHERE
  CHARINDEX('<a href=', P.Body COLLATE Latin1_General_BIN) <> 0
GROUP BY SUBSTRING(
  P.Body COLLATE Latin1_General_BIN,
  CHARINDEX('<a href=', P.Body COLLATE Latin1_General_BIN)+9,
  CHARINDEX(
    '/',
    P.Body COLLATE Latin1_General_BIN,
    CHARINDEX('<a href=', P.Body COLLATE Latin1_General_BIN)+9+8
  )-(CHARINDEX('<a href=', P.Body COLLATE Latin1_General_BIN)+9)
)
HAVING COUNT(*) >= 10
ORDER BY [Count] DESC

Results

  • Blender (run query):

    • blend-exchange.giantcowfilms.com -> posts (6.3k+)
    • blend-exchange.com -> posts (4.8k+)
    • drive.google.com -> posts (2.8k+)
    • dropbox.com -> posts (1.0k+)
    • pasteall.org -> posts (1.2k+). This domain is no longer a file sharing site, and redirects to a different sketchy site. I've raised this on their meta: What to do with all the links to pasteall?.
    • mediafire.com -> posts (300+)

    See also their highly voted Allow permanent blend file hosting

  • Ask Ubuntu (run query):

    • paste.ubuntu.com -> posts (3.7k+). See also How should users share long log files? and Does paste.ubuntu.com remove all old snippets?. The site itself literally says:

      This site is intended for use as a short-term exchange of pasted information between parties. All submitted data is considered public information. Submitted data is not guaranteed to be permanent, and may be removed at any time.

    • pastebin.com -> posts (2.3k+). The site's FAQ states:

      At this moment in time we do not delete pastes that do not have an expiration date. But in the future we might automatically delete pastes that have not been viewed by anyone in more than 6 months. Again, this is not something we are doing at this moment. But we might start doing it in the future.

    • dropbox.com -> posts (700+)

You can run it on other sites using the site selection menu.

Okay, so what?

I mean- this is a lot of off-site content. I just gives me some whiplash in the brain that we're so insistent on making sure we protect against link rot, and yet all the above is fine enough to ignore? And what about the nightmare scenarios? We're just fine with what happened with pasteall.org?

Don't get me wrong. I'm not saying that every site really needs this. And if it were to be implemented, I'd be very concerned about it being used when it doesn't need to be, or as a crutch for not putting in the effort to make a minimal reproducible example on Stack Overflow. And probably security needs significant consideration and corresponding protection mechanisms too.

I'm just trying to look at what's happening on the ground, and wonder if it's fine with us. Particularly, Blender seems to have a real use-case and need. And I say this as someone looking in at them from the outside.

1
  • 1
    Maybe worth adding TL;DR in the beginning, explaining the gist of the answer? While I'm still against having Stack Exchange host files, you do raise valid point, but in the current state of the answer, it requires some reading to get to it. Commented Nov 11, 2023 at 9:15
1

It is not likely that StackOverflow will implement file uploads into their service. They are trying to discourage people posting files with hundreds or thousands of lines of coding and expecting someone to spend all their time looking for the problem. Instead, S.O. wants people to only post the snippet of code which has problems so that people can easily detect the problem without breaking a sweat and to save server storage space.

However, you do have a good point for programming languages that do not exist in the form of plain text or have to interact with other elements to function, such as the old version of GameMaker (version 8.0 and below, not GameMaker: Studio). If you don't want to hear me brag about GameMaker: Studio, skip the next paragraph.

GameMaker: Studio appears to have a few removed object actions from my experience. Some actions were unknown when I opened up an object in a project file. I find it a bit slower and harder to use than V8.0.

Unlike GameMaker Studio, where you can paste the code for certain parts of a project, GameMaker files cannot be simply viewed as readable plain text and normally problems are hidden in different parts of the file than what you think.

If you want to give people access to the files that have problems, which you should only do when you really need to, consider file sharing services like DropBox or Google Drive. While Google Drive gives you 15GB of free storage while Dropbox only gives you 2GB free, Dropbox does not care about executable files where as Google Drive will try to stop you in case of it being a virus.

Don't ask people to download the program you used to create the project file. I learned that the hard way.

2
  • GitHub might be better than Dropbox or google drive Commented Nov 10, 2023 at 22:16
  • @TheEmptyStringPhotographer why better? There is one answer suggesting this, but without explaining, if you'll add answer explaining the benefits of using GH it might be useful. Thanks. Commented Nov 11, 2023 at 9:21
0

If you’re knowledgeable with HTML + JavaScript, you can add a code snippet that will download a file to your computer.

-1

I've read a couple of the responses falling on the side of the argument that uploading code might be a bad thing.

Configuring and building projects can be a difficult task, especially for beginners - and sharing a Visual Studio solution may be the only way readers can determine the cause of the problem.

In short, I think uploading would be a great feature.

Youtube can store and serve all that video, so what's a few source code files by comparison?! Isn't that what the Internet's all about?

I take onboard that there are free hosting sites that specialize in hosting files, but providing a git / SVN compatible interface to SO to allow users to upload files or projects would greatly add to the quality of Stack Overflow. IMHO.

0
-1

For small binary files, you can insert a code block containing the file’s base64-encoded contents directly within a post, using the uuencode -m command. It looks like this:

begin-base64 644 test.txt
VGhpcyBpcyBhbiBleGFtcGxlIGJpbmFyeSBmaWxlIQo=
====

The maximum length of an answer is 50 thousand characters; the overhead of base64 encoding alone makes that 37.5 kB of binary data. If you subtract the size of any surrounding text, this should suffice for files up to about 20 kB in size, although using compression you might be able to squeeze a bit more out of that. Ah, just like in the good ol’ days of alt.binaries.er… er, .slack. Yes, alt.binaries.slack.

I’ve even got a proof-of-concept user script that adds a download button to code blocks formatted in this way. Adding upload functionality should not be too hard, though so far I have not had much need for it myself; command line is sufficient for me now.

1
  • 2
    Code block should be used for, well, code. Using it to "host" files is abuse of the system, and would waste time of people who would have to check it's not malicious. If I'll notice user abusing it often I'll flag, and hopefully others too. Commented Nov 10, 2023 at 16:47
-4

No one wants to dig through an entire project to find the problem but sometimes when i post a question i think the problem lies in one part of my code but it really is something else entirely. It would be nice to be able to say here's the relevant code but here is the full file just in case my problem is in a different part. If we narrow the scope to including one file not an entire project i think is a perfectly acceptable thing to do. it should not necessarily be hosted on stack overflow but i think posting a link to the file instead of dumping it all into the question is a much better approach.

2
  • The problem with posting content outside of the SE environment is that the links may eventually rot, removing any value that the OP had. In most cases, the questioner should reduce the problem to a minimal example, which you can post completely as part of the question.
    – Werner
    Commented Nov 10, 2014 at 21:58
  • @Werner I disagree that the OP would lose all value as a result of a dead link to a file. IT only has potential to help the question and solution be more complete. If the link dies and the Q&A are better because of it that death doesn't matter so much because that's not where the value lies.
    – spintron
    Commented Nov 11, 2014 at 9:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .