473,772 Members | 3,603 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

image uploads and version control?

I'm developing a php website that I have under subversion version
control. I'm working on an image upload functionality, and in the
middle of it I realized that any files that a user uploads will not be
under version control, and if I checkout or export the site from
version control, and deploy it, it won't bring any of the uploaded
files with it.

I'm looking at php subversion functions, but the manual says that
they're experimental, and my webhost hasn't deployed them.

What's a workaround for this? I'm thinking that I'll have to have a
parallel site for image hosting. For example, I'll have
images.website. com, hosted under a separate filesystem directory, and
then in the actual website that a user would peruse, any img src would
reference images.website. com . When I accept my uploads, I'll do my
filesystem copy to the images filesystem link.

Thoughts?
Oct 10 '08
12 1803
On Oct 13, 12:38*pm, Michael Fesser <neti...@gmx.de wrote:
.oO(lawp...@gma il.com)
>
Well, I can do all that in one fell swoop by creating a symbolic link.
I don't have to worry about whether or not I've deleted anything in
version control that I then need to remove in the production; it's
already done for me. If I had to delete files what were already
deleted in version control, then in my mind, I'm doing manual labor
that the computer should be doing anyway.

That's what synchronizing is for. The computer can easily check which
files have been modified or deleted from the working copy and upload all
required changes to the production server. There are various tools
available for this task.
I suppose there are tools for this. Care to give me a sales pitch on
any of them? Right now an svn export does everything I want, with no
risks of the downsides of copying or synchronizing.
And the deployment tool is built right into the version control
system. Why do I need an extra tool here?
>
Also, by using symbolic links, I can deploy, test, and fallback to the
old directory by re-linking very easily if I need to.

This should happen on a testing server. You hardly need multiple
versions on the production server.
That would always work if the development and production environments
were identical, but in my experience, they're not. Code that passes a
test in the development environment might still have problems when you
roll it out in production. And then that happens, you'll want to roll
it back *really really badly*. :)

The situation I've been involved in before was where we made a change
to the database structure in development which we didn't replicate in
the production database. The code was developed and tested in
production against a new table structure, and it passed all its test.
Then when we went to roll it out, SQL errors all over the place. It
was quite a relief to be able to roll back the website with a simple
command. ( BTW, I'd really like a smart version control system for our
table structure, one that could do ALTER TABLEs appropriately when
deploying).

In our situation, we have a development server, and a production
server with a staging hostname and a production hostname. Once a
feature pasts testing on development, it goes out to staging. Staging
is on the production server and connects to the production database.
We do 'pre-live' testing there.

The great part about this is the seamless deployment from stating to
production. Our initial svn export gets linked to the staging
hostname. E.g.:
$ls
website-release-320
staging.website .com -website-release-320/
website.com -website-release-320/
$svn export http://svn-host/website/releases/release-345 ./website-
release-345
$rm -rf stating.website .com; ln -s ./website-release-345
staging.website .com
$ls
website-release-320
website-release-345
staging.website .com -website-release-345/
website.com -website-release-320/

Where staging.website .com was previously linked to ./website-
release-320 . Now the new code really is in the production
environment. There shouldn't be any problem in production that
wouldn't be apparent here. So, after we've done the testing at
staging, we do:

$rm -rf website.com; ln -s website-release-320 website.com
$ls
website-release-320
website-release-345
staging.website .com -website-release-345/
website.com -website-release-345/

The deployment of the new code to live takes milliseconds.

We can let the 320 revision hang around for a while; it's not being
served, and it's a "known good configuration" of the website
( provided it doesn't reference any outdated database structures :)
that we can rollback to if needed.
Finally, by using an adequately named directory to symlink to, I know
what version I have deployed as production. If /home/user/website/
production is a symlink to /home/user/website/trunk-R255, then there's
a pretty good chance that it's revision 255 that is currently in
production. If I were just copying files into the website directory, I
would have to have another way to know or guess what revision was
actually deployed.

You could use tags on your repository and then simply assume that it's
always the latest tagged version which goes production. When you reach
the next stable release, tag it and deploy it. Quite easy.
That's a good idea. We're suing subversion, which doesn't have tags,
but the manual says you get the same functionality by doing a release
branch.

Knowing myself and my computing habits, I wouldn't like to assume that
a directory is the latest tagged released; it may not be. ( My most
difficult bash-head-against-wall troubleshooting cases are always
faulty assumptions ). By creating a directory named trunk-R273 or
release-R503, then there's a greater likelihood that that directory
actually *contains* revision 503. Not that there's anything magical in
naming it as such, but hopefully when I'm improperly naming a
directory ( e.g. svn export http://svn-host/releases/R502 ./website-
release-R498 ), the cognitive dissonance becomes apparent, and I stop
and say "Hey, what am I doing? This is *wrong*!" For me at least,
there's a lesser likelihood of that happening when I'm doing export to
the generic directory name that we've been using for years.
Oct 13 '08 #11
On Mon, 13 Oct 2008 08:58:12 -0700 (PDT), la*****@gmail.c om wrote in
<12************ *************** *******@k7g2000 hsd.googlegroup s.com>:
>On Oct 13, 11:30*am, Charles Calvert <cb...@yahoo.co mwrote:
>On Mon, 13 Oct 2008 06:23:48 -0700 (PDT), lawp...@gmail.c om wrote in
<7edb880b-1c8e-4060-b59c-e2ecd2d0d...@v7 2g2000hsv.googl egroups.com>:
>On Oct 13, 12:06*am, Charles Calvert <cb...@yahoo.co mwrote:
>I think that I must have misunderstood, because it sounds like you
want to use Subversion as a packaging and distribution mechanism, and
that's not what it's for.
>Well, here's the problem, as I perceive it:
[snip]
>Users of the website need to be able to upload images, which in the
current incarnation of the website I specified to be served /home/user/
website/images. This directory currently holds all images served with
the site, not just user uploaded images.
>My 'packaging and distribution' practice currently consists of 'svn
exporthttp://svn-host/website/trunk', and then linking that to the
website directory, e.g. 'ln -s website-trunk-revision-189 /home/user/
website'.

I would just get the desired revision from svn and copy the source
files to the production directory. *You might need to clean out the
production directory first if you've removed any files.

Well, I can do all that in one fell swoop by creating a symbolic link.
I don't have to worry about whether or not I've deleted anything in
version control that I then need to remove in the production; it's
already done for me. If I had to delete files what were already
deleted in version control, then in my mind, I'm doing manual labor
that the computer should be doing anyway.

Also, by using symbolic links, I can deploy, test, and fallback to the
old directory by re-linking very easily if I need to.

Finally, by using an adequately named directory to symlink to, I know
what version I have deployed as production. If /home/user/website/
production is a symlink to /home/user/website/trunk-R255, then there's
a pretty good chance that it's revision 255 that is currently in
production.
This was the part that I was missing. It sounded like the working
copy was being used for production. You're not doing that. What you
are doing sounds reasonable.

[snip]
>You're making this too complex. Subversion is for controling
revisions of your source code and related files (e.g. design docs),
nothing else. Once you put the application into production and have
begun accumulating user data, just copy the source files from a
working directory to the production directory using cp -r or a shell
script.

Well, I didn't *intentionally* make it to complex; my assumptions
about website design and structure sort of led me to the place that
I'm in now. :)

I'm making a dymanimc website where users can input data. The source
code of the website is under version control, and the user-generated
data is stored in MySQL. So far, so good. If I needed to re-generate
the website for any reason ( backup, new webhost, errant rm -rf ), all
I needed was a recent export from subversion and the latest MySQL
dump.
Check. That's the same strategy I use.
>So now I think I'm beginning to understand the philosophy. In the
past, I could get away with keeping all the website images under /
images, or some similar structure.
Assuming that they are part of the application and not user content,
that makes perfect sense. After all, version control can work for
images too.
>But now that I'm accepting user data that I can't or shouldn't put
into MySQL, I need to find a third place to store things. I liked
the simplicity of having the whole website existing as svn export +
mysqldump, so I was hoping there was a way I could keep this new
kind of data within that system. But I can't. Now, the website must
be mysqldump + svn + some other thing.
Right. You could combine the mysqldump and the back-up of the
extradatabase user content into a single script and just tar
everything up together into a single back-up file. That should be a
fairly simple shell script, perhaps with the revision number as a
parameter that can be appended to the name of the tarball, much like
you're doing with the directories.
--
Charles Calvert | Web-site Design/Development
Celtic Wolf, Inc. | Software Design/Development
http://www.celticwolf.com/ | Data Conversion
(703) 580-0210 | Project Management
Oct 28 '08 #12
AqD
On Oct 11, 3:25 am, lawp...@gmail.c om wrote:
I'm developing a php website that I have under subversion version
control. I'm working on an image upload functionality, and in the
middle of it I realized that any files that a user uploads will not be
under version control, and if I checkout or export the site from
version control, and deploy it, it won't bring any of the uploaded
files with it.

I'm looking at php subversion functions, but the manual says that
they're experimental, and my webhost hasn't deployed them.

What's a workaround for this? I'm thinking that I'll have to have a
parallel site for image hosting. For example, I'll have
images.website. com, hosted under a separate filesystem directory, and
then in the actual website that a user would peruse, any img src would
reference images.website. com . When I accept my uploads, I'll do my
filesystem copy to the images filesystem link.

Thoughts?
it could be done. Just call the "svn" commands in your code.

But it sucks in my experience to use large binary files (hundreds of
KBs) with subversion. The status (scanning / detecting) and exporting/
updating are painfully slow compared to direct copy.
Oct 31 '08 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
11763
by: dave | last post by:
Hello there, I am at my wit's end ! I have used the following script succesfully to upload an image to my web space. But what I really want to be able to do is to update an existing record in a table in MySQL with the path & filename to the image. I have successfully uploaded and performed an update query on the database, but the problem I have is I cannot retain the primary key field in a variable which is then used in a SQL update...
2
1877
by: Paul Gorman | last post by:
I am using the control type = file to perform a file upload. When I click on the browse button to go select the image I want to upload it places in the text box a local path (C:\images\image.jpg for example). This is where the image resides that I want to upload. Then I proceed to click on upload so that I can run through my code to do the upload process: string strConnection = "some connection string"; SqlConnection oCon = new...
2
2363
by: Tim T | last post by:
Hi, Could someone please point to to a tutorial / code for dynamically resizing images on upload, THEN saving to disk on the webserver. I need users to be able to upload images to my server, but they will not be aware of optimising graphics for the web, if someone uploads a 300k 640x480 jpeg for example, i need to be able to shrink it down to a - say 400x300 65k file BEFORE saving to my webserver. I have been looking on the web and have...
2
318
by: Ryan Moore | last post by:
I am creating a site that has an "Uploads" directory where users can upload image files (let's say .jpgs and .gifs). When a user uploads an image, the system creates a directory within this "Uploads" directory to place their image in. What I would like to do is protect the ENTIRE uploads directory so a user cannot navigate directly to http://mysite/uploads/2/img.jpg without logging into the site first (I'm using forms authentication). I'm...
7
3400
by: Scott Schluer | last post by:
Is there a way to use the Image class to convert a color photo (GIF or JPEG) to a B&W photo? Thanks, Scott
7
3346
by: Jake Barnes | last post by:
I've a little webcam program that snaps a picture of me and uploads it every 20 seconds. It automatically uploads the image to my server. It always give the image the same name, and thus it overwrites the image that has been there for the last 20 seconds. People can, if they wish, hit the refresh button every 20 seconds, but I thought it would be fun to have a Javascript function that actually refreshed the image. However, this following...
9
2596
by: tshad | last post by:
This was posted before but the message got messed up (all NLs were stripped out for some reason). I have 2 labels that hold the name of different images on my .aspx page. <asp:Label ID="Logo" runat="server"/> <asp:Label ID="CompanyPicture" runat="server"/> I have 2 links that open the windows to preview these images. The previewed images are done on separate html pages that do nothing but display the
3
1225
by: adamjblakey | last post by:
Hi, Can anyone see what is wrong with this function. The problem is that when it creates the 450px image it comes out black and not in colour like the thumbnail. Any ideas? <?php function uploadimage($value){ $file_type = $value; $file_name = $value;
0
9620
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10261
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10104
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10038
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9912
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8934
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6715
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.